本文整理汇总了Python中tkinter.BooleanVar方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.BooleanVar方法的具体用法?Python tkinter.BooleanVar怎么用?Python tkinter.BooleanVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.BooleanVar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_parameters_frame
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def create_parameters_frame(self, parent):
parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
parameters.grid(sticky='nsew')
heading = ttk.Label(parameters, text='Analysis parameters')
heading.grid(column=0, row=0, sticky='n')
for i, param in enumerate(self.parameters, start=1):
param_label = ttk.Label(parameters, text=param._name)
param_label.grid(row=i, column=0, sticky='nsew')
if type(param) == tk.BooleanVar:
param_entry = ttk.Checkbutton(parameters, variable=param)
elif hasattr(param, '_choices'):
param_entry = ttk.OptionMenu(parameters, param, param.get(),
*param._choices.keys())
else:
param_entry = ttk.Entry(parameters, textvariable=param)
param_entry.grid(row=i, column=1, sticky='nsew')
示例2: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def __init__(self, parent, mainWindow, **kwargs):
tk.Frame.__init__(self, parent, **kwargs)
self.parent = parent
self.mainWindow = mainWindow
self.columnconfigure(1, weight=1)
tk.Frame(self, height="20", width="10").grid(row="0", column="1", columnspan="2")
checkboxValue = tk.BooleanVar()
checkboxValue.set(settings.detailsWindowShow)
self.windowDisabled = tk.Checkbutton(self, text="Show Pilot Breakdown window", variable=checkboxValue)
self.windowDisabled.var = checkboxValue
self.windowDisabled.grid(row="1", column="1", columnspan="2")
tk.Frame(self, height="20", width="10").grid(row="2", column="1", columnspan="2")
self.makeListBox()
示例3: create_variables
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def create_variables(self):
settings = TkUtil.Settings.Data
self.restore = settings.get_bool(GENERAL, RESTORE, True)
self.menuImages = {}
self.toolbarImages = {}
self.toolbars = []
self.toolbarMenu = None
self.dockWindows = []
self.dockWindowMenu = None
self.statusText = tk.StringVar()
self.fontFamily = tk.StringVar()
self.fontPointSize = tk.StringVar()
self.bold = tk.BooleanVar()
self.italic = tk.BooleanVar()
self.alignment = tk.StringVar()
self.recentFiles = []
self.findDialog = None
self.x = self.y = self.dock = None
示例4: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def __init__(self, master, options):
self.options = options
board = self.options.board
self.columns = tk.StringVar()
self.columns.set(board.columns)
self.rows = tk.StringVar()
self.rows.set(board.rows)
self.maxColors = tk.StringVar()
self.maxColors.set(board.maxColors)
self.delay = tk.StringVar()
self.delay.set(board.delay)
self.restore = tk.BooleanVar()
self.restore.set(self.options.restore)
self.showToolbar = tk.BooleanVar()
self.showToolbar.set(self.options.showToolbar)
super().__init__(master, "Preferences — {}".format(APPNAME),
TkUtil.Dialog.OK_BUTTON|TkUtil.Dialog.CANCEL_BUTTON)
示例5: set
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def set(self, value, *args, **kwargs):
if type(self.variable) == tk.BooleanVar:
self.variable.set(bool(value))
elif self.variable:
self.variable.set(value, *args, **kwargs)
elif type(self.input) in (ttk.Checkbutton, ttk.Radiobutton):
if value:
self.input.select()
else:
self.input.deselect()
elif type(self.input) == tk.Text:
self.input.delete('1.0', tk.END)
self.input.insert('1.0', value)
else:
self.input.delete(0, tk.END)
self.input.insert(0, value)
示例6: load_settings
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [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)
示例7: set
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def set(self, value, *args, **kwargs):
if type(self.variable) == tk.BooleanVar:
self.variable.set(bool(value))
elif self.variable:
self.variable.set(value, *args, **kwargs)
elif type(self.input).__name__.endswith('button'):
if value:
self.input.select()
else:
self.input.deselect()
elif type(self.input) == tk.Text:
self.input.delete('1.0', tk.END)
self.input.insert('1.0', value)
else:
self.input.delete(0, tk.END)
self.input.insert(0, value)
示例8: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def __init__(self, master=None, text="", width=20, compound=tk.LEFT, **kwargs):
"""
Create a ToggledFrame.
:param master: master widget
:type master: widget
:param text: text to display next to the toggle arrow
:type text: str
:param width: width of the closed ToggledFrame (in characters)
:type width: int
:param compound: "center", "none", "top", "bottom", "right" or "left":
position of the toggle arrow compared to the text
:type compound: str
:param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
"""
ttk.Frame.__init__(self, master, **kwargs)
self._open = False
self.__checkbutton_var = tk.BooleanVar()
self._open_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "open.png")))
self._closed_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "closed.png")))
self._checkbutton = ttk.Checkbutton(self, style="Toolbutton", command=self.toggle,
variable=self.__checkbutton_var, text=text, compound=compound,
image=self._closed_image, width=width)
self.interior = ttk.Frame(self, relief=tk.SUNKEN)
self._grid_widgets()
示例9: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [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
示例10: get_tk_var
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [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
示例11: set_vars
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [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
示例12: _set_modified_vars
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BooleanVar [as 别名]
def _set_modified_vars(self):
""" Set the tkinter variable for each tab to indicate whether contents
have been modified """
tkvars = dict()
for tab in self.tab_names:
if tab == "tools":
for ttab in self.tools_tab_names:
var = tk.BooleanVar()
var.set(False)
tkvars[ttab] = var
continue
var = tk.BooleanVar()
var.set(False)
tkvars[tab] = var
logger.debug("Set modified vars: %s", tkvars)
return tkvars