本文整理汇总了Python中Tkinter.StringVar方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.StringVar方法的具体用法?Python Tkinter.StringVar怎么用?Python Tkinter.StringVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.StringVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, root, resource_dir, lang="fr"):
ttk.Frame.__init__(self, root)
self.resource_dir = resource_dir
self._lang = None
langs = os.listdir(os.path.join(self.resource_dir, "master"))
if langs:
self._lang = (lang if lang in langs else langs[0])
self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
self.items.sort(key=lambda x: x.lower())
max_length = max([len(item) for item in self.items])
self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
#strVar = tkinter.StringVar()
self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)
for item in self.items:
self.masters.insert(tkinter.END, item)
示例2: select
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def select(message="", title="Lackey Input", options=None, default=None):
""" Creates a dropdown selection dialog with the specified message and options
`default` must be one of the options.
Returns the selected value. """
if options is None or len(options) == 0:
return ""
if default is None:
default = options[0]
if default not in options:
raise ValueError("<<default>> not in options[]")
root = tk.Tk()
input_text = tk.StringVar()
input_text.set(message)
PopupList(root, message, title, options, default, input_text)
root.focus_force()
root.mainloop()
return str(input_text.get())
示例3: win1
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def win1():
# this is the main/root window
root = Tkinter.Tk()
root.title("Window 1")
startButton = Tkinter.Button(root, text="Start", command=win2)
startButton.grid(row=9, column=7)
leaveButton = Tkinter.Button(root, text="Quit", command=root.destroy)
leaveButton.grid(row=1, column=1, sticky='nw')
b1Var = Tkinter.StringVar()
b2Var = Tkinter.StringVar()
b1Var.set('b1')
b2Var.set('b2')
box1Label = Tkinter.Label(root,textvariable=b1Var,width=12)
box1Label.grid(row=3, column=2)
box2Label = Tkinter.Label(root,textvariable=b2Var,width=12)
box2Label.grid(row=3, column=3)
root.mainloop()
示例4: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, parent):
self.parent = parent
self.dirname = ''
self.dir_opt = {}
self.field_dict = {}
self.message = StringVar()
# Determine if PyDICOM python library is present.
deidentifier_tool = methods.find_deidentifier_tool()
if not deidentifier_tool:
error = "ERROR: PyDICOM does not appear to be installed.\n " \
+ "Please make sure PyDICOM has been properly installed " \
+ "before using the DICOM deidentifier tab.\n " \
+ "Check the README.md of the DICAT repository for " \
+ "information on how to install PyDICOM."
self.message.set(error)
self.initialize()
示例5: _init_toolbar
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def _init_toolbar(self):
xmin, xmax = self.canvas.figure.bbox.intervalx
height, width = 50, xmax-xmin
Tk.Frame.__init__(self, master=self.window,
width=int(width), height=int(height),
borderwidth=2)
self.update() # Make axes menu
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
# spacer, unhandled in Tk
pass
else:
button = self._Button(text=text, file=image_file,
command=getattr(self, callback))
if tooltip_text is not None:
ToolTip.createToolTip(button, tooltip_text)
self.message = Tk.StringVar(master=self)
self._message_label = Tk.Label(master=self, textvariable=self.message)
self._message_label.pack(side=Tk.RIGHT)
self.pack(side=Tk.BOTTOM, fill=Tk.X)
示例6: _dyn_option_menu
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def _dyn_option_menu(parent): # htest #
from Tkinter import Toplevel
top = Toplevel()
top.title("Tets dynamic option menu")
top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
parent.winfo_rooty() + 150))
top.focus_set()
var = StringVar(top)
var.set("Old option set") #Set the default value
dyn = DynOptionMenu(top,var, "old1","old2","old3","old4")
dyn.pack()
def update():
dyn.SetMenu(["new1","new2","new3","new4"], value="new option set")
button = Button(top, text="Change option set", command=update)
button.pack()
示例7: configure_canvas
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def configure_canvas(self):
self.figure = Figure(dpi=100)
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
self.axis = self.figure.add_subplot(111)
self.canvas.draw()
canvas_widget = self.canvas.get_tk_widget()
canvas_widget.grid(row=0, column=0, sticky=tk.N + tk.W + tk.E + tk.S)
self.canvas_cursor = Cursor(self.axis, tk.StringVar(master=self.root))
self.canvas.mpl_connect('motion_notify_event', self.canvas_cursor.mouse_move)
self.span = SpanSelector(
self.axis, self.zoom, 'horizontal', useblit=True,
rectprops=dict(alpha=0.5, facecolor='red'))
self.mz_span = None
self.scan = None
self.annotations = []
self.canvas.draw()
示例8: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, master, radios, font, changed, **kwargs):
tk.Frame.__init__(self, master)
self.master = master
self.radios = radios
self.font = font
self.changed = changed
self.scrollv = tk.Scrollbar(self, orient = "vertical")
self.textbox = tk.Text(self, yscrollcommand = self.scrollv.set, **kwargs)
self.scrollv.config(command = self.textbox.yview)
# layout.
self.scrollv.pack(side = "right", fill = "y")
self.textbox.pack(side = "left", fill = "both", expand = True)
# create radiobuttons.
self.radiovar = tk.StringVar()
self.radiovar.set('FILE')
self.create()
示例9: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, text, cfg, key, optional=False):
self.entry = None
self.enabled = True
self.value = tk.StringVar()
self.text = text
self.cfg = cfg
self.key = key
self.optional = optional
try:
if self.cfg[self.key] is None:
self.value.set("")
else:
self.value.set(self.cfg[self.key])
except KeyError:
self.value.set("")
示例10: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, root=None):
self.root=Tkinter.Frame(root)
self.root.pack(side='top')
self.path=Tkinter.StringVar() # For Song Path
self.song_time=Tkinter.StringVar() # For Song Playing Time
self.song_duration=Tkinter.StringVar() # For Song Duration
self.volume=Tkinter.IntVar() # For Song Volume
# ============= Creating Media Player ======================================================
mediaplayer=player.mediaplayer(self.path, self.song_time, self.song_duration, self.volume)
# ============= Creating Display Panel ======================================================
DisplayPanel.Player(self.root, self.path, self.song_time, self.song_duration)
# ============= Creating Control Panel ======================================================
lit2=Controls(self.root, self.path, mediaplayer, self.volume)
self.hook2=lit2
# ============= Here Connecting List Panel ======================================================
lit=ListPanel.main(self.root, self.path)
self.hook=lit.hook
示例11: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, master):
tk.Frame.__init__(self, master)
self.pack(padx=20, pady=20)
self.master = master
self.selection = tk.StringVar()
self.selection.set('white')
tk.Label(self, text="These are radiobuttons").pack()
tk.Radiobutton(self, text='White', value='white', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Red', value='red', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Green', value='green', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Blue', value='blue', variable=self.selection, command=self.set_color).pack(anchor='w')
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:20,代码来源:Tkinter_Widget_Examples.py
示例12: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, notebook, fileName, console):
ClosableTab.__init__(self, notebook, fileName, console)
self.analysis = Analysis(fileName)
sub_tabs = ValidationTabs(self.frame)
main_frame = sub_tabs.add("Main Settings")
correction_frame = sub_tabs.add("Correction Settings")
s1Var = tk.StringVar()
s2Var = tk.StringVar()
s1Var.set(self.analysis.s1)
s2Var.set(self.analysis.s2)
square1Label = tk.Label(main_frame.frame,textvariable=s1Var)
square1Label.grid(row=0, column=7)
square2Label = tk.Label(main_frame.frame,textvariable=s2Var)
square2Label.grid(row=0, column=6)
sub_tabs.pack()
main_frame.validate(False)
notebook.pack(expand=1, fill='both')
示例13: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def __init__(self, notebook, fileName, console):
ClosableTab.__init__(self, notebook, fileName, console)
self.analysis = configuration.AnalysisConfiguration(fileName)
sub_tabs = ValidationTabs(self.frame)
main_frame = sub_tabs.add("Main Settings")
correction_frame = sub_tabs.add("Correction Settings")
s1Var = tk.StringVar()
s2Var = tk.StringVar()
s1Var.set(self.analysis.s1)
s2Var.set(self.analysis.s2)
square1Label = tk.Label(main_frame.frame,textvariable=s1Var)
square1Label.grid(row=0, column=7)
square2Label = tk.Label(main_frame.frame,textvariable=s2Var)
square2Label.grid(row=0, column=6)
sub_tabs.pack()
main_frame.validate(False)
notebook.pack(expand=1, fill='both')
示例14: kimmoHelp
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def kimmoHelp(self,*args):
# helpText = """
# """
# load help into helpfile
# helpText = Tkinter.StringVar()
helpText = ''
try: f = open(self.helpFilename, 'r')
except IOError, e:
self.guiError("HelpFile not loaded")
return
示例15: _make_file_select
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import StringVar [as 别名]
def _make_file_select(self, parent, rowidx, label):
# Create string variable.
tkstr = tk.StringVar()
# Create callback event handler.
cmd = lambda: self._file_select(tkstr)
# Create the Label, Entry, and Button objects.
label = tk.Label(parent, text=label)
entry = tk.Entry(parent, textvariable=tkstr)
button = tk.Button(parent, text='...', command=cmd)
label.grid(row=rowidx, column=0, sticky='W')
entry.grid(row=rowidx, column=1)
button.grid(row=rowidx, column=2)
return tkstr
# Set status text, and optionally update cursor.