Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the fine-tuning box Spinbox of Tkinter

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Tkinter fine-tuning frame Spinbox how to use the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Tkinter fine-tuning frame Spinbox how to use the article will have a harvest, let's take a look.

The Spinbox control can be used to select a number from a set of data, or to fine-tune a set value.

First of all, prepare fonts and information labels:

# create fontftTimes = Font (family='Times', size=12, weight=BOLD)

# create a label to display message.label_text = StringVar () label = Label (root, textvariable=label_text) label.grid (row=2, column=0, columnspan=2, sticky=E + W)

Generate a Spinbox for text selection:

# value changed handling.def spin_changed (* args): # get current value and set to label. Label_text.set (tb.get ())

# create a Radiobutton for Teacher.tb = Spinbox (root,values= ('Teacher',' Student', 'Worker'), state='readonly', background= "# ffffa0", foreground= "# ff0000", activebackground= "# a0ffa0", command=spin_changed, font=ftTimes) tb.grid (row=0, column=0, columnspan=1, sticky=W)

The spin_changed function is used to handle the representation when the selection changes. It is specified by the command property when building the Spinbox control, and its content is obtained using the get method of Spinbox and set to the label control.

Spinbox specifies an optional collection through the values property. State is specified as' readonly' to restrict user input.

The second Spinbox is a digital fine-tuning box with the following code:

# control variable of value spinbox.vb_var = StringVar () vb_var.set ('0.6')

Def isOkay (text): if text = ='-': return True if len (text) = 0: return True value = int (float (text) * 100) if-100

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report