Python GUI----Spinbox

Source: Internet
Author: User



1. Create a Spinbox

From tkinter Import *root = Tk () spinbox (Root). Pack () Root.mainloop ()

2. Set the maximum, minimum, and stride values for the Spinbox

root = Tk () spinbox (root,        from_ = 0,      #设置最小值 to        =,       #设置最大值        increment = 5   #设置增量值为5, This is the same as the resolution meaning of scale        ). Pack () Root.mainloop ()
3. Set the attribute values, after setting this value, each update value will use the value specified

From tkinter Import *root = Tk () sb = Spinbox (root, values = (0,2,20,40,-1), #显示的第一个值为0, and increments according to the index of the tuple, to the most The latter item will no longer increase increment = 2) sb.pack () print (sb[' values ')             #输出值为0 2 40-1root.mainloop ()
4. Print the current content of the Spinbox, which is the displayed value, not the value of values.

From tkinter Import *root = Tk () def printspin ():    # Use the Get () method to get the current display value of    print (Sb.get ()) sb = Spinbox (Root,                   From_ = 0,         #最小值 to             = ten,           #最大值             command = printspin# callback function             ) Sb.pack () Root.mainloop ()
5. Delete and insert
root = Tk () #作用是删除values第一位def printspin ():    sb.delete (0)                    #在索引位置0处删除    print (Sb.get ()) sb = Spinbox (Root,                   from_ = 1,             #最小值 to             = 9999,             #最大值             increment = 1,             command = Printspin    #回调函数             ) # The following two sentences are assigned the initial value of the Spinbox 9988. Read a good document, do not know the correct wording is what, the first to replace the Sb.delete (0)                      Sb.insert (end,9988)                 #在索引结尾插入sb. Pack () Root.mainloop ()




Python GUI----Spinbox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.