本文整理汇总了Python中tkinter.DoubleVar方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.DoubleVar方法的具体用法?Python tkinter.DoubleVar怎么用?Python tkinter.DoubleVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.DoubleVar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master, gui):
super().__init__(master, text="output: Tremolo")
self.gui = gui
self.input_waveform = tk.StringVar()
self.input_waveform.set("<off>")
self.input_rate = tk.DoubleVar()
self.input_depth = tk.DoubleVar()
self.input_rate.set(5)
self.input_depth.set(80)
row = 0
tk.Label(self, text="waveform").grid(row=row, column=0)
values = ["<off>", "sine", "triangle", "sawtooth", "square"]
menu = tk.OptionMenu(self, self.input_waveform, *values)
menu["width"] = 10
menu.grid(row=row, column=1)
row += 1
tk.Label(self, text="rate").grid(row=row, column=0, sticky=tk.E)
tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_rate, from_=0.0, to=10.0, resolution=.1,
width=10, length=100).grid(row=row, column=1)
row += 1
tk.Label(self, text="depth").grid(row=row, column=0, sticky=tk.E)
tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_depth, from_=0.0, to=1.0, resolution=.02,
width=10, length=100).grid(row=row, column=1)
示例2: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, *args, min_var=None, max_var=None,
focus_update_var=None, from_='-Infinity', to='Infinity',
**kwargs):
super().__init__(*args, from_=from_, to=to, **kwargs)
self.resolution = Decimal(str(kwargs.get('increment', '1.0')))
self.precision = self.resolution.normalize().as_tuple().exponent
# there should always be a variable,
# or some of our code will fail
self.variable = kwargs.get('textvariable') or tk.DoubleVar()
if min_var:
self.min_var = min_var
self.min_var.trace('w', self._set_minimum)
if max_var:
self.max_var = max_var
self.max_var.trace('w', self._set_maximum)
self.focus_update_var = focus_update_var
self.bind('<FocusOut>', self._set_focus_update_var)
示例3: load_settings
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def load_settings(self):
"""Load settings into our self.settings dict."""
vartypes = {
'bool': tk.BooleanVar,
'str': tk.StringVar,
'int': tk.IntVar,
'float': tk.DoubleVar
}
# create our dict of settings variables from the model's settings.
self.settings = {}
for key, data in self.settings_model.variables.items():
vartype = vartypes.get(data['type'], tk.StringVar)
self.settings[key] = vartype(value=data['value'])
# put a trace on the variables so they get stored when changed.
for var in self.settings.values():
var.trace('w', self.save_settings)
示例4: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, STATE):
self.STATE = STATE
self.STATE.trw_completed = StringVar(self.STATE.mainGUI)
self.STATE.trw_completed.set("Not run")
self.STATE.rotation_voltage = DoubleVar(self.STATE.mainGUI)
self.STATE.rotation_voltage.set(2)
self.STATE.angular_mode = BooleanVar(self.STATE.mainGUI)
self.STATE.angular_mode.set(False)
self.stored_data = {}
self.queue = queue.Queue()
self.mode = "disabled"
self.data = []
self.lock = threading.Condition()
# Tells the listener to not store data
self.discard_data = True
# Last telemetry data received from the robot
self.last_data = (0,) * 20
示例5: get
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def get(self):
""" Return the value from the tk_var
Notes
-----
tk variables don't like empty values if it's not a stringVar. This seems to be pretty
much the only reason that a get() call would fail, so replace any numerical variable
with it's numerical zero equivalent on a TCL Error. Only impacts variables linked
to Entry widgets.
"""
try:
val = self.tk_var.get()
except TclError:
if isinstance(self.tk_var, tk.IntVar):
val = 0
elif isinstance(self.tk_var, tk.DoubleVar):
val = 0.0
else:
raise
return val
示例6: get_tk_var
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def get_tk_var(self, track_modified):
""" Correct variable type for control """
if self.dtype == bool:
var = tk.BooleanVar()
elif self.dtype == int:
var = tk.IntVar()
elif self.dtype == float:
var = tk.DoubleVar()
else:
var = tk.StringVar()
logger.debug("Setting tk variable: (name: '%s', dtype: %s, tk_var: %s)",
self.name, self.dtype, var)
if track_modified and self._command is not None:
logger.debug("Tracking variable modification: %s", self.name)
var.trace("w",
lambda name, index, mode, cmd=self._command: self._modified_callback(cmd))
if track_modified and self._command in ("train", "convert") and self.title == "Model Dir":
var.trace("w", lambda name, index, mode, v=var: self._model_callback(v))
return var
示例7: set_vars
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def set_vars():
""" Analysis specific vars """
enabled = tk.BooleanVar()
enabled.set(True)
ready = tk.BooleanVar()
ready.set(False)
modified = tk.DoubleVar()
modified.set(None)
tk_vars = {"enabled": enabled,
"ready": ready,
"modified": modified}
logger.debug(tk_vars)
return tk_vars
# INFO LABEL
示例8: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master):
# More advanced as compared to regular buttons
# Check buttons can also store binary values
self.checkbutton = ttk.Checkbutton(master, text = 'Check Me!')
self.checkbutton.pack()
self.label = ttk.Label(master, text = 'Ready!! Nothing has happened yet.')
self.label.pack()
# Tkinter variable classes
# self.boolvar = tk.BooleanVar() # boolean type variable of tk
# self.dblvar = tk.DoubleVar() # double type variable of tk
# self.intvar = tk.IntVar() # int type variable of tk
self.checkme = tk.StringVar() # string type variable of tk
self.checkme.set('NULL') # set value for string type tkinter variable
print('Current value of checkme variable is \'{}\''.format(self.checkme.get()))
# setting of binary value for check button: 1. onvaalue and 2. offvalue
self.checkbutton.config(variable = self.checkme, onvalue = 'I am checked!!', offvalue = 'Waiting for someone to check me!')
self.checkbutton.config(command = self.oncheckme)
# creating another tkinter string type variable - StringVar
self.papertype = tk.StringVar() # created a variable
self.radiobutton1 = ttk.Radiobutton(master, text = 'Paper1', variable=self.papertype, value = 'Robotics Research')
self.radiobutton1.config(command = self.onselectradio)
self.radiobutton1.pack()
self.radiobutton2 = ttk.Radiobutton(master, text = 'Paper2', variable=self.papertype, value = 'Solid Mechanics Research')
self.radiobutton2.config(command = self.onselectradio)
self.radiobutton2.pack()
self.radiobutton3 = ttk.Radiobutton(master, text = 'Paper3', variable=self.papertype, value = 'Biology Research')
self.radiobutton3.config(command = self.onselectradio)
self.radiobutton3.pack()
self.radiobutton4 = ttk.Radiobutton(master, text = 'Paper4', variable=self.papertype, value = 'SPAM Research')
self.radiobutton4.config(command = self.onselectradio)
self.radiobutton4.pack()
self.radiobutton5 = ttk.Radiobutton(master, text = 'Change Checkme text', variable=self.papertype, value = 'Radio Checkme Selected')
self.radiobutton5.pack()
self.radiobutton5.config(command = self.onradiobuttonselect)
示例9: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def __init__(self, master):
ttk.Label(master, text = "PROGRESS CONTROL").pack()
# Inderterminant Progressbar
ttk.Label(master, text = 'Inderterminant Progress').pack()
self.prgrsbr_indtr = ttk.Progressbar(master, orient = tk.HORIZONTAL, length = 300, mode = 'indeterminate')
self.prgrsbr_indtr.pack()
self.checkpbi = tk.StringVar()
self.checkpbi.set("Start")
# Button
self.btn1 = ttk.Button(master, text = "{} Inderterminant Progress Bar".format(self.checkpbi.get()), command = self.btn1cmd)
self.btn1.pack()
# Derterminant progress
ttk.Label(master, text = 'Derterminant Progress').pack()
self.prgrsbr_dtr = ttk.Progressbar(master, orient=tk.HORIZONTAL, length = 300, mode = 'determinate')
self.prgrsbr_dtr.pack()
self.prgrsbr_dtr.config(maximum = 10.0, value = 2.0) # notice both these properties have float values
# Button
ttk.Button(master, text = 'Reset Progress Bar to zero', command = self.resetProgressBarVal).pack()
# Button
ttk.Button(master, text = 'Increase Progress Bar by 2', command = self.shift2ProgressBarVal).pack()
# create double variable
self.prgrsBrVal = tk.DoubleVar()
self.prgrsbr_dtr.config(variable = self.prgrsBrVal) # set variable property of progressbar to look at DoubleVar()
# Scale widget
self.scalebar = ttk.Scale(master, orient = tk.HORIZONTAL, length = 400, variable=self.prgrsBrVal, from_ = 0.0, to= 10.0)
self.scalebar.pack()
# Label to display current value of scalebar
ttk.Label(master, text = "Current value of Progress Bar is as below:").pack()
self.scalebar_label = ttk.Label(master, textvariable = self.prgrsBrVal)
self.scalebar_label.pack()
示例10: start_progress_bar
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def start_progress_bar(self, path):
'''Pop up a progress bar starting at 0% while the wordlist is processing
'''
self.progress_path = path
self.progress_popup = Tk.Toplevel()
self.progress_popup.title('Processing')
self.progress_popup.resizable(width=False, height=False)
self.progress_popup.grab_set()
self.progress_popup.overrideredirect(1)
progress_frame = Tk.Frame(self.progress_popup, borderwidth=1, relief=Tk.RAISED)
progress_frame.pack(side='top', fill='both', padx=10, pady=10)
path_label = Tk.Label(progress_frame, text='', font=('Helvetica', '12'))
path_label.pack(padx=10, pady=10)
path_label.configure(text="Processing to '{}'...".format(path))
self.progress_var = Tk.DoubleVar()
self.progress_bar = ttk.Progressbar(progress_frame, variable=self.progress_var,
length=300, maximum=100, style='plain.Horizontal.TProgressbar')
self.progress_bar.pack(side='left', padx=10, pady=10)
self.progress_percent_lb = Tk.Label(progress_frame, text='', font=('Helvetica', '12'))
self.progress_percent_lb.pack(side='left', padx=10, pady=10)
self.progress_percent_lb.configure(text='0%')
def stop(): self.controller.stop_processing_flag = True
self.progress_btn = Tk.Button(progress_frame, text='Cancel', command=stop)
self.progress_btn.pack(side='left', padx=10, pady=20)
center_window(self.progress_popup, self.master)
self.progress_popup.update()
示例11: add_entry
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def add_entry(self, **kwargs):
"""
To add an entry box. The adding of the entry box will add an attribute,
if no variable is specified.
args:
- vartype: to specify which type the variable associated with the entry
will be. Useful to make sure the user does not enter a string when a
number is expected.
- variable: the variables name, which will be set as an attribute.
- width : the width of the entry box.
"""
widgets_dict = kwargs.pop('widgets_dict', None)
frame = kwargs.pop('frame', None)
entry_name = kwargs.pop('name', 'name')
width = kwargs.pop('width', 10)
vartype = kwargs.pop('vartype', tk.DoubleVar())
variable = kwargs.pop("variable", None)
if not variable:
setattr(self, entry_name + '_var', vartype)
widgets_dict[entry_name] = tk.Entry(frame,
textvariable=getattr(self, entry_name+
'_var'),
width=width)
else:
widgets_dict[entry_name] = tk.Entry(frame,
textvariable=variable,
width=width)
示例12: setUp
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import DoubleVar [as 别名]
def setUp(self):
self.value = tk.DoubleVar()
self.vsb = widgets.ValidatedSpinbox(
self.root,
textvariable=self.value,
from_=-10, to=10, increment=1
)
self.vsb.pack()
self.vsb.wait_visibility()