本文整理汇总了Python中tkinter.IntVar方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.IntVar方法的具体用法?Python tkinter.IntVar怎么用?Python tkinter.IntVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.IntVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def find(self, text_to_find):
length = tk.IntVar()
idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length)
if idx:
self.tag_remove('find_match', 1.0, tk.END)
end = f'{idx}+{length.get()}c'
self.tag_add('find_match', idx, end)
self.see(idx)
self.find_search_starting_index = end
self.find_match_index = idx
else:
if self.find_match_index != 1.0:
if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"):
self.find_search_starting_index = 1.0
self.find_match_index = None
return self.find(text_to_find)
else:
msg.showinfo("No Matches", "No matching text found")
示例2: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def __init__(self, parent=None, title="", decimalPlaces=0, inThousands=0, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
gridFrame = self._nametowidget(parent.winfo_parent())
self.parent = self._nametowidget(gridFrame.winfo_parent())
self.grid(row="0", column="0", sticky="ew")
self.columnconfigure(0,weight=1)
self.singleLabel = singleLabel = tk.Label(self, text=title)
singleLabel.grid(row="0",column="0", sticky="ew")
self.listbox = listbox = tk.Spinbox(self, from_=0, to=9, width=1, borderwidth=1, highlightthickness=0)
listbox.delete(0,tk.END)
listbox.insert(0,decimalPlaces)
listbox.grid(row="0", column="1")
checkboxValue = tk.IntVar()
checkboxValue.set(inThousands)
self.checkbox = checkbox = tk.Checkbutton(self, text="K", variable=checkboxValue, borderwidth=0, highlightthickness=0)
checkbox.var = checkboxValue
checkbox.grid(row="0", column="2")
singleLabel.bind("<Button-1>", lambda e:self.dragStart(e, listbox, checkbox))
示例3: create_infos
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def create_infos(self):
self.info_frame = tk.Frame()
self.info_frame.grid(row=0,column=1)
self.fps_label = tk.Label(self.info_frame,text="fps:")
self.fps_label.pack()
self.auto_range = tk.IntVar()
self.range_check = tk.Checkbutton(self.info_frame,
text="Auto range",variable=self.auto_range)
self.range_check.pack()
self.auto_apply = tk.IntVar()
self.auto_apply_check = tk.Checkbutton(self.info_frame,
text="Auto apply",variable=self.auto_apply)
self.auto_apply_check.pack()
self.minmax_label = tk.Label(self.info_frame,text="min: max:")
self.minmax_label.pack()
self.range_label = tk.Label(self.info_frame,text="range:")
self.range_label.pack()
self.bits_label = tk.Label(self.info_frame,text="detected bits:")
self.bits_label.pack()
self.zoom_label = tk.Label(self.info_frame,text="Zoom: 100%")
self.zoom_label.pack()
self.reticle_label = tk.Label(self.info_frame,text="Y:0 X:0 V=0")
self.reticle_label.pack()
示例4: load_settings
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [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)
示例5: _Button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def _Button(self, text, image_file, toggle, frame):
if image_file is not None:
im = tk.PhotoImage(master=self, file=image_file)
else:
im = None
if not toggle:
b = tk.Button(master=frame, text=text, padx=2, pady=2, image=im,
command=lambda: self._button_click(text))
else:
# There is a bug in tkinter included in some python 3.6 versions
# that without this variable, produces a "visual" toggling of
# other near checkbuttons
# https://bugs.python.org/issue29402
# https://bugs.python.org/issue25684
var = tk.IntVar()
b = tk.Checkbutton(master=frame, text=text, padx=2, pady=2,
image=im, indicatoron=False,
command=lambda: self._button_click(text),
variable=var)
b._ntimage = im
b.pack(side=tk.LEFT)
return b
示例6: isearch
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def isearch(self, pattern, *args, **kwargs):
"""
Just search shortcut, in the sense it return the matched chunk
the initial position and the end position.
"""
count = IntVar()
index = self.search(pattern, *args, count=count, **kwargs)
if not index: return
len = count.get()
tmp = '%s +%sc' % (index, len)
chunk = self.get(index, tmp)
pos0 = self.index(index)
pos1 = self.index('%s +%sc' % (index, len))
return chunk, pos0, pos1
示例7: set
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def set(self, value):
"""
Set a new value.
Check whether value is in limits first. If not, return False and set
the new value to either be the minimum (if value is smaller than the
minimum) or the maximum (if the value is larger than the maximum).
Both str and int are supported as value types, as long as the str
contains an int.
:param value: new value
:type value: int
"""
if not isinstance(value, int):
raise TypeError("value can only be of int type")
limited_value = max(min(self._high, value), self._low)
tk.IntVar.set(self, limited_value)
# Return False if the value had to be limited
return limited_value is value
示例8: _Button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def _Button(self, text, image_file, toggle, frame):
if image_file is not None:
im = Tk.PhotoImage(master=self, file=image_file)
else:
im = None
if not toggle:
b = Tk.Button(master=frame, text=text, padx=2, pady=2, image=im,
command=lambda: self._button_click(text))
else:
# There is a bug in tkinter included in some python 3.6 versions
# that without this variable, produces a "visual" toggling of
# other near checkbuttons
# https://bugs.python.org/issue29402
# https://bugs.python.org/issue25684
var = Tk.IntVar()
b = Tk.Checkbutton(master=frame, text=text, padx=2, pady=2,
image=im, indicatoron=False,
command=lambda: self._button_click(text),
variable=var)
b._ntimage = im
b.pack(side=Tk.LEFT)
return b
示例9: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def __init__(self, parent):
tk.LabelFrame.__init__(self, parent)
self.title = tk.Label(self, text='SV Length')
self.len_GT_On = tk.IntVar(value=0)
self.len_GT_On_CB = tk.Checkbutton(self, text=">", justify=tk.LEFT, variable=self.len_GT_On)
self.len_GT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
self.len_GT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)
self.len_LT_On = tk.IntVar(value=0)
self.len_LT_On_CB = tk.Checkbutton(self, text="<", justify=tk.LEFT, variable=self.len_LT_On)
self.len_LT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
self.len_LT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)
self.title.grid(row=0, column=0, sticky=tk.EW, columnspan=4)
self.len_GT_On_CB.grid(row=1, column=0, sticky=tk.EW)
self.len_GT_val.grid(row=2, column=0, sticky=tk.EW)
self.len_GT_Units.grid(row=2, column=1, sticky=tk.EW)
self.len_LT_On_CB.grid(row=1, column=2, sticky=tk.EW)
self.len_LT_val.grid(row=2, column=2, sticky=tk.EW)
self.len_LT_Units.grid(row=2, column=3, sticky=tk.EW)
示例10: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def __init__(self, parent, *args, **kw):
super().__init__(parent, *args, **kw)
self.parent = parent
self.data_from_file_lbl = None
self.solution_tab = None
self.model_solutions = None
self.param_strs = None
self.ranks = None
self.params = None
self.categorical = None
self.run_date = None
self.total_seconds = 0
self.progress_bar = None
self.status_lbl = None
self.solution_format_var = IntVar()
self.create_widgets()
示例11: _create_file_format_btn
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def _create_file_format_btn(self, btn_text, var_value, parent, column):
''' Creates and grids Radiobutton used for choosing solution file
format.
Args:
btn_text (str): text displayed next to the Radiobutton.
var_value (int): value of the IntVar associated with this
Radiobutton.
parent (Tk object): parent of this Radiobutton.
column (int): column index where this Radiobutton
should be gridded.
'''
sol_format_btn = Radiobutton(parent, text=btn_text,
variable=self.solution_format_var,
value=var_value)
sol_format_btn.grid(row=2, column=column, sticky=W+N, padx=2)
示例12: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def __init__(self, parent, current_categories, data_from_params_file,
str_var_for_input_output_boxes, weights_status_str,
*args, **kw):
Notebook.__init__(self, parent, *args, **kw)
self.parent = parent
self.params = Parameters()
self.current_categories = current_categories
self.input_categories_frame = None
self.output_categories_frame = None
self.params_from_file_lbl = None
self.data_from_params_file = data_from_params_file
self.str_var_for_input_output_boxes = str_var_for_input_output_boxes
self.weight_tab = None
self.load_without_data = IntVar()
self.options_frame = None
self.create_widgets(weights_status_str)
示例13: radio_btn_change
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def radio_btn_change(self, name, *args):
''' Actions that happen when user clicks on a Radiobutton.
Changes the corresponding parameter values and options.
Args:
name (str): name of the parameter that is a key in
options dictionary.
*args: are provided by IntVar trace method and are
ignored in this method.
'''
count = self.options[name].get()
self.params.update_parameter(name, COUNT_TO_NAME_RADIO_BTN[name, count])
dea_form = COUNT_TO_NAME_RADIO_BTN[name, count]
if self.max_slack_box: # on creation it is None
if dea_form == 'multi':
# disable max slacks
self.max_slack_box.config(state=DISABLED)
self.params.update_parameter('MAXIMIZE_SLACKS', '')
elif dea_form == 'env':
self.max_slack_box.config(state=NORMAL)
if self.options['MAXIMIZE_SLACKS'].get() == 1:
self.params.update_parameter('MAXIMIZE_SLACKS', 'yes')
示例14: highlight
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def highlight(self, event=None):
length = tk.IntVar()
for category in self.categories:
matches = self.categories[category]['matches']
for keyword in matches:
start = 1.0
keyword = keyword + "[^A-Za-z_-]"
idx = self.text_widget.search(keyword, start, stopindex=tk.END, count=length, regexp=1)
while idx:
char_match_found = int(str(idx).split('.')[1])
line_match_found = int(str(idx).split('.')[0])
if char_match_found > 0:
previous_char_index = str(line_match_found) + '.' + str(char_match_found - 1)
previous_char = self.text_widget.get(previous_char_index, previous_char_index + "+1c")
if previous_char.isalnum() or previous_char in self.disallowed_previous_chars:
end = f"{idx}+{length.get() - 1}c"
start = end
idx = self.text_widget.search(keyword, start, stopindex=tk.END, regexp=1)
else:
end = f"{idx}+{length.get() - 1}c"
self.text_widget.tag_add(category, idx, end)
start = end
idx = self.text_widget.search(keyword, start, stopindex=tk.END, regexp=1)
else:
end = f"{idx}+{length.get() - 1}c"
self.text_widget.tag_add(category, idx, end)
start = end
idx = self.text_widget.search(keyword, start, stopindex=tk.END, regexp=1)
self.highlight_regex(r"(\d)+[.]?(\d)*", "number")
self.highlight_regex(r"[\'][^\']*[\']", "string")
self.highlight_regex(r"[\"][^\']*[\"]", "string")
示例15: highlight_regex
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import IntVar [as 别名]
def highlight_regex(self, regex, tag):
length = tk.IntVar()
start = 1.0
idx = self.text_widget.search(regex, start, stopindex=tk.END, regexp=1, count=length)
while idx:
end = f"{idx}+{length.get()}c"
self.text_widget.tag_add(tag, idx, end)
start = end
idx = self.text_widget.search(regex, start, stopindex=tk.END, regexp=1, count=length)