本文整理汇总了Python中tkinter.StringVar.trace_variable方法的典型用法代码示例。如果您正苦于以下问题:Python StringVar.trace_variable方法的具体用法?Python StringVar.trace_variable怎么用?Python StringVar.trace_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.StringVar
的用法示例。
在下文中一共展示了StringVar.trace_variable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Select_Py_Version
# 需要导入模块: from tkinter import StringVar [as 别名]
# 或者: from tkinter.StringVar import trace_variable [as 别名]
class Select_Py_Version(_Dialog):
"""
Select_Py_Version is a tkinter pop-up dialog used to select a python
interpreter for use with Tk_Nosy.
"""
def body(self, master):
dialogframe = Frame(master, width=300, height=300)
dialogframe.pack()
self.Label_1 = Label(dialogframe, text="Select Python Version")
self.Label_1.pack()
if self.dialogOptions:
rbL = self.dialogOptions.get('rbL', ['No Options','No Options'])
else:
rbL = ['No Options', 'No Options']
self.RadioGroup1_StringVar = StringVar()
self.RadioGroup1_StringVar.set(rbL[0])
self.RadioGroup1_StringVar_traceName = \
self.RadioGroup1_StringVar.trace_variable("w", self.RadioGroup1_StringVar_Callback)
for rb in rbL:
self.Radiobutton_1 = Radiobutton(dialogframe, text=rb, value=rb)
self.Radiobutton_1.pack(anchor=W)
self.Radiobutton_1.configure( variable=self.RadioGroup1_StringVar )
self.resizable(0, 0) # Linux may not respect this
def RadioGroup1_StringVar_Callback(self, varName, index, mode):
"""When radio group selection changes, print message to CLI."""
print( "RadioGroup1_StringVar_Callback varName, index, mode",
varName, index, mode )
print( " new StringVar value =", self.RadioGroup1_StringVar.get() )
def validate(self):
"""Validates and packages dialog selections prior to return to calling
routine.
set values in "self.result" dictionary for return
"""
self.result = {} # return a dictionary of results
self.result["selection"] = self.RadioGroup1_StringVar.get()
return 1
def apply(self):
print( 'apply called')