本文整理汇总了Python中Tkinter.BooleanVar方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.BooleanVar方法的具体用法?Python Tkinter.BooleanVar怎么用?Python Tkinter.BooleanVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.BooleanVar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_entryconfigure_variable
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def test_entryconfigure_variable(self):
m1 = self.create()
v1 = tkinter.BooleanVar(self.root)
v2 = tkinter.BooleanVar(self.root)
m1.add_checkbutton(variable=v1, onvalue=True, offvalue=False,
label='Nonsense')
self.assertEqual(str(m1.entrycget(1, 'variable')), str(v1))
m1.entryconfigure(1, variable=v2)
self.assertEqual(str(m1.entrycget(1, 'variable')), str(v2))
示例2: test_default
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def test_default(self):
v = BooleanVar(self.root)
self.assertEqual(False, v.get())
示例3: test_get
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def test_get(self):
v = BooleanVar(self.root, True, "name")
self.assertAlmostEqual(True, v.get())
self.root.globalsetvar("name", "0")
self.assertAlmostEqual(False, v.get())
示例4: test_invalid_value_domain
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def test_invalid_value_domain(self):
v = BooleanVar(self.root, name="name")
self.root.globalsetvar("name", "value")
with self.assertRaises(TclError):
v.get()
self.root.globalsetvar("name", "1.0")
with self.assertRaises(TclError):
v.get()
示例5: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def __init__(self, root):
'''Initialize Variables that save search state.
The dialogs bind these to the UI elements present in the dialogs.
'''
self.root = root # need for report_error()
self.patvar = StringVar(root, '') # search pattern
self.revar = BooleanVar(root, False) # regular expression?
self.casevar = BooleanVar(root, False) # match case?
self.wordvar = BooleanVar(root, False) # match whole word?
self.wrapvar = BooleanVar(root, True) # wrap around buffer?
self.backvar = BooleanVar(root, False) # search backwards?
# Access methods
示例6: set_tk_var
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def set_tk_var():
global address
address = StringVar()
address.set(read_config("Proxy", "Address", "str"))
global port
port = IntVar()
port.set(read_config("Proxy", "Port", "int"))
global protocol
protocol = StringVar()
protocol.set(read_config("Proxy", "Protocol", "str"))
global username
username = StringVar()
username.set(read_config("Proxy", "Username", "str"))
global password
password = StringVar()
password.set(read_config("Proxy", "Password", "str"))
global proxy_path_var
proxy_path_var = StringVar()
proxy_path = read_config("Proxy", "Path", "str")
if len(proxy_path) == 0:
proxy_path = path.join(data_dir, 'proxy.txt')
proxy_path_var.set(proxy_path)
global proxy_api
proxy_api = StringVar()
proxy_api.set(read_config("Proxy", "API", "str"))
global test_address
test_address = StringVar()
test_address.set(read_config("Proxy", "TestAddress", "str"))
global use_proxy
use_proxy = BooleanVar()
use_proxy.set(read_config("Proxy", "Proxy", "boolean"))
示例7: set_tk_var
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def set_tk_var():
global method
method = StringVar()
method.set(read_config("Config", "Method", "str"))
global server
server = StringVar()
server.set(read_config("Config", "Server", "str"))
global shelltype
shelltype = StringVar()
shelltype.set(read_config("Config", "ShellType", "str"))
global parameter
parameter = StringVar()
parameter.set(read_config("Config", "Parameter", "str"))
global thread_num
thread_num = IntVar()
thread_num.set(read_config("Config", "ThreadNumber", "int"))
global req_delay
req_delay = DoubleVar()
req_delay.set(read_config("Config", "RequestDelay", "float"))
global time_out
time_out = DoubleVar()
time_out.set(read_config("Config", "RequestTimeout", "float"))
global random_ua
random_ua = BooleanVar()
random_ua.set(read_config("Config", "RandomUserAgent", "boolean"))
global con_close
con_close = BooleanVar()
con_close.set(read_config("Config", "ConnectionClose", "boolean"))
global keep_alive
keep_alive = BooleanVar()
keep_alive.set(read_config("Config", "KeepAlive0", "boolean"))
global custom_hdr
custom_hdr = BooleanVar()
custom_hdr.set(read_config("Config", "CustomRequestHeader", "boolean"))
global custom_hdr_data
custom_hdr_data = StringVar()
custom_hdr_data.set(read_config("Config", "CustomRequestHeaderData", "str"))
示例8: define_variables
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def define_variables(self):
self.solver_name = tk.StringVar(self.master)
self.function = tk.StringVar(self.master)
self.popsize = tk.IntVar(self.master)
self.max_iter = tk.IntVar(self.master)
self.interval = tk.IntVar(self.master)
self.mcmc_stepsize_x1 = tk.DoubleVar(self.master)
self.mcmc_stepsize_x2 = tk.DoubleVar(self.master)
self.hmc_stepsize = tk.DoubleVar(self.master)
self.log_mcmc_stepsize_x1 = tk.DoubleVar(self.master)
self.log_mcmc_stepsize_x2 = tk.DoubleVar(self.master)
self.log_hmc_stepsize = tk.DoubleVar(self.master)
self.n_leap = tk.IntVar(self.master)
self.w = tk.DoubleVar(self.master)
self.c1 = tk.DoubleVar(self.master)
self.c2 = tk.DoubleVar(self.master)
self.gamma = tk.DoubleVar(self.master)
self.CR = tk.DoubleVar(self.master)
self.F = tk.DoubleVar(self.master)
self.strategy = tk.StringVar(self.master)
self.sigma = tk.DoubleVar(self.master)
self.mu_perc = tk.DoubleVar(self.master)
self.seed = tk.IntVar(self.master)
self.fix_seed = tk.BooleanVar(self.master)
self.constrain = tk.BooleanVar(self.master)
self.sync = tk.BooleanVar(self.master)
示例9: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def __init__(self, text, cfg, key):
self.checkbox = None
self.enabled = True
self.value = tk.BooleanVar()
self.text = text
self.cfg = cfg
self.key = key
try:
if self.cfg[self.key] not in (True, False):
self.value.set(False)
else:
self.value.set(self.cfg[self.key])
except KeyError:
self.value.set(False) # default to False
示例10: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def __init__(self, version):
tk.Tk.__init__(self)
self.title("Enrich 2 Configurator v{}".format(version))
self.treeview = None
self.treeview_popup_target_id = None
self.cfg_file_name = tk.StringVar()
self.element_dict = dict()
self.root_element = None
# analysis options
self.scoring_method = tk.StringVar()
self.logr_method = tk.StringVar()
self.force_recalculate = tk.BooleanVar()
self.component_outliers = tk.BooleanVar()
self.plots_requested = tk.BooleanVar()
self.tsv_requested = tk.BooleanVar()
# allow resizing
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
# create UI elements
self.create_main_frame()
self.create_menubar()
self.create_treeview_context_menu()
示例11: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def __init__(self, title='AirtestX Basic GUI', ratio=0.5, device=None):
self._device = device
self._root = tk.Tk()
self._root.title(title)
self._queue = Queue()
self._refresh_text = tk.StringVar()
self._refresh_text.set("Refresh")
self._gencode_text = tk.StringVar()
self._genfile_name = tk.StringVar()
self._fileext_text = tk.StringVar()
self._auto_refresh_var = tk.BooleanVar()
self._uiauto_detect_var = tk.BooleanVar()
self._attachfile_text = tk.StringVar()
self._running = False # if background is running
self._init_items()
self._init_thread()
self._init_refresh()
self._lastx = 0
self._lasty = 0
self._bounds = None # crop area
self._center = (0, 0) # center point
self._offset = (0, 0) # offset to image center
self._poffset = (0, 0)
self._size = (90, 90)
self._moved = False # click or click and move
self._color = 'red' # draw color
self._tkimage = None # keep reference
self._image = None
self._ratio = ratio
self._uinodes = [] # ui dump
self._selected_node = None
self._hovered_node = None
self._save_parent_dir = None
self._init_vars()
示例12: setupOptFlags
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def setupOptFlags(self):
self.optFlags = []
flags = []
if hasattr(self.options, 'optFlags'):
flags.extend(self.options.optFlags)
d = {}
soFar = {}
for meth in reflect.prefixedMethodNames(self.options.__class__, 'opt_'):
full = 'opt_' + meth
func = getattr(self.options, full)
if not usage.flagFunction(func) or meth in ('help', 'version'):
continue
if soFar.has_key(func):
continue
soFar[func] = 1
existing = d.setdefault(func, meth)
if existing != meth:
if len(existing) < len(meth):
d[func] = meth
for (func, name) in d.items():
flags.append((name, None, func.__doc__))
if len(flags):
self.optFrame = f = Tkinter.Frame(self)
for (flag, _, desc) in flags:
b = Tkinter.BooleanVar()
c = Tkinter.Checkbutton(f, text=desc, variable=b, wraplen=200)
c.pack(anchor=Tkinter.W)
self.optFlags.append((flag, b))
f.grid(row=1, column=1)
示例13: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BooleanVar [as 别名]
def __init__(self, parent, name):
Tkinter.Frame.__init__(self, parent)
self.checked = Tkinter.BooleanVar()
checkbox = Tkinter.Checkbutton(self, variable=self.checked, command=save,
padx=0, pady=0)
checkbox.grid(row=0, column=0, sticky='E')
nameLabel = Tkinter.Label(self, text=name, padx=0, pady=0)
nameLabel.grid(row=0, column=1, sticky='W')
self.batteryLabel = Tkinter.Label(self, text="", fg="#999999", padx=0, pady=0)
self.batteryLabel.grid(row=1, column=0, columnspan=2, sticky='E')
self.versionLabel = Tkinter.Label(self, text="", fg="#999999", padx=0, pady=0)
self.versionLabel.grid(row=2, column=0, columnspan=2, sticky='E')
# construct all the checkboxes