本文整理汇总了Python中Tkinter.IntVar方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.IntVar方法的具体用法?Python Tkinter.IntVar怎么用?Python Tkinter.IntVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.IntVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plugin_prefs
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def plugin_prefs(parent, cmdr, is_beta):
PADX = 10
BUTTONX = 12 # indent Checkbuttons and Radiobuttons
PADY = 2 # close spacing
output = config.getint('output') or (config.OUT_MKT_EDDN | config.OUT_SYS_EDDN) # default settings
eddnframe = nb.Frame(parent)
HyperlinkLabel(eddnframe, text='Elite Dangerous Data Network', background=nb.Label().cget('background'), url='https://github.com/EDSM-NET/EDDN/wiki', underline=True).grid(padx=PADX, sticky=tk.W) # Don't translate
this.eddn_station= tk.IntVar(value = (output & config.OUT_MKT_EDDN) and 1)
this.eddn_station_button = nb.Checkbutton(eddnframe, text=_('Send station data to the Elite Dangerous Data Network'), variable=this.eddn_station, command=prefsvarchanged) # Output setting
this.eddn_station_button.grid(padx=BUTTONX, pady=(5,0), sticky=tk.W)
this.eddn_system = tk.IntVar(value = (output & config.OUT_SYS_EDDN) and 1)
this.eddn_system_button = nb.Checkbutton(eddnframe, text=_('Send system and scan data to the Elite Dangerous Data Network'), variable=this.eddn_system, command=prefsvarchanged) # Output setting new in E:D 2.2
this.eddn_system_button.grid(padx=BUTTONX, pady=(5,0), sticky=tk.W)
this.eddn_delay= tk.IntVar(value = (output & config.OUT_SYS_DELAY) and 1)
this.eddn_delay_button = nb.Checkbutton(eddnframe, text=_('Delay sending until docked'), variable=this.eddn_delay) # Output setting under 'Send system and scan data to the Elite Dangerous Data Network' new in E:D 2.2
this.eddn_delay_button.grid(padx=BUTTONX, sticky=tk.W)
return eddnframe
示例2: adjust
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def adjust(self, naxes):
if self._naxes < naxes:
for i in range(self._naxes, naxes):
self._axis_var.append(Tk.IntVar())
self._axis_var[i].set(1)
self._checkbutton.append( self._mbutton.menu.add_checkbutton(
label = "Axis %d" % (i+1),
variable=self._axis_var[i],
command=self.set_active))
elif self._naxes > naxes:
for i in range(self._naxes-1, naxes-1, -1):
del self._axis_var[i]
self._mbutton.menu.forget(self._checkbutton[i])
del self._checkbutton[i]
self._naxes = naxes
self.set_active()
示例3: __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)
示例4: crear_widgets
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def crear_widgets(self):
self.var = IntVar()
self.background_label = Label(self.container,
image=self.imagen_fondo)
txt = "Selecciona una choza en la que entrar. Ganarás si:\n"
txt += "La choza está vacia o si su ocupante es tu aliado, de lo contrario morirás"
self.info_label = Label(self.container, text=txt, bg='white')
# Creamos un dicionario con las opciones para las imagenes de las chozas
r_btn_config = {'variable': self.var,
'bg': '#8AA54C',
'activebackground': 'green',
'image': self.imagen_choza,
'height': self.alto_choza,
'width': self.ancho_choza,
'command': self.radio_btn_pressed}
self.r1 = Radiobutton(self.container, r_btn_config, value=1)
self.r2 = Radiobutton(self.container, r_btn_config, value=2)
self.r3 = Radiobutton(self.container, r_btn_config, value=3)
self.r4 = Radiobutton(self.container, r_btn_config, value=4)
self.r5 = Radiobutton(self.container, r_btn_config, value=5)
示例5: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [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
示例6: _init_fonts
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def _init_fonts(self, root):
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
root.option_add("*Font", self._sysfont)
# TWhat's our font size (default=same as sysfont)
self._size = Tkinter.IntVar(root)
self._size.set(self._sysfont.cget('size'))
self._boldfont = tkFont.Font(family='helvetica', weight='bold',
size=self._size.get())
self._font = tkFont.Font(family='helvetica',
size=self._size.get())
示例7: _init_animation
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def _init_animation(self):
# Are we stepping? (default=yes)
self._step = Tkinter.IntVar(self._root)
self._step.set(1)
# What's our animation speed (default=fast)
self._animate = Tkinter.IntVar(self._root)
self._animate.set(3) # Default speed = fast
# Are we currently animating?
self._animating = 0
示例8: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def __init__(self):
tk.Tk.__init__(self)
self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
self.title('GooMPy')
self.canvas = tk.Canvas(self, width=WIDTH, height=HEIGHT)
self.canvas.pack()
self.bind("<Key>", self.check_quit)
self.bind('<B1-Motion>', self.drag)
self.bind('<Button-1>', self.click)
self.label = tk.Label(self.canvas)
self.radiogroup = tk.Frame(self.canvas)
self.radiovar = tk.IntVar()
self.maptypes = ['roadmap', 'terrain', 'satellite', 'hybrid']
self.add_radio_button('Road Map', 0)
self.add_radio_button('Terrain', 1)
self.add_radio_button('Satellite', 2)
self.add_radio_button('Hybrid', 3)
self.zoom_in_button = self.add_zoom_button('+', +1)
self.zoom_out_button = self.add_zoom_button('-', -1)
self.zoomlevel = ZOOM
maptype_index = 0
self.radiovar.set(maptype_index)
self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)
self.restart()
示例9: plugin_prefs
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def plugin_prefs(parent, cmdr, is_beta):
PADX = 10
BUTTONX = 12 # indent Checkbuttons and Radiobuttons
PADY = 2 # close spacing
frame = nb.Frame(parent)
frame.columnconfigure(1, weight=1)
HyperlinkLabel(frame, text='Inara', background=nb.Label().cget('background'), url='https://inara.cz/', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) # Don't translate
this.log = tk.IntVar(value = config.getint('inara_out') and 1)
this.log_button = nb.Checkbutton(frame, text=_('Send flight log and Cmdr status to Inara'), variable=this.log, command=prefsvarchanged)
this.log_button.grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W)
nb.Label(frame).grid(sticky=tk.W) # big spacer
this.label = HyperlinkLabel(frame, text=_('Inara credentials'), background=nb.Label().cget('background'), url='https://inara.cz/settings-api', underline=True) # Section heading in settings
this.label.grid(columnspan=2, padx=PADX, sticky=tk.W)
this.apikey_label = nb.Label(frame, text=_('API Key')) # EDSM setting
this.apikey_label.grid(row=12, padx=PADX, sticky=tk.W)
this.apikey = nb.Entry(frame)
this.apikey.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
prefs_cmdr_changed(cmdr, is_beta)
return frame
示例10: plugin_prefs
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def plugin_prefs(parent, cmdr, is_beta):
PADX = 10
BUTTONX = 12 # indent Checkbuttons and Radiobuttons
PADY = 2 # close spacing
frame = nb.Frame(parent)
frame.columnconfigure(1, weight=1)
HyperlinkLabel(frame, text='Elite Dangerous Star Map', background=nb.Label().cget('background'), url='https://www.edsm.net/', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) # Don't translate
this.log = tk.IntVar(value = config.getint('edsm_out') and 1)
this.log_button = nb.Checkbutton(frame, text=_('Send flight log and Cmdr status to EDSM'), variable=this.log, command=prefsvarchanged)
this.log_button.grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W)
nb.Label(frame).grid(sticky=tk.W) # big spacer
this.label = HyperlinkLabel(frame, text=_('Elite Dangerous Star Map credentials'), background=nb.Label().cget('background'), url='https://www.edsm.net/settings/api', underline=True) # Section heading in settings
this.label.grid(columnspan=2, padx=PADX, sticky=tk.W)
this.cmdr_label = nb.Label(frame, text=_('Cmdr')) # Main window
this.cmdr_label.grid(row=10, padx=PADX, sticky=tk.W)
this.cmdr_text = nb.Label(frame)
this.cmdr_text.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.W)
this.user_label = nb.Label(frame, text=_('Commander Name')) # EDSM setting
this.user_label.grid(row=11, padx=PADX, sticky=tk.W)
this.user = nb.Entry(frame)
this.user.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
this.apikey_label = nb.Label(frame, text=_('API Key')) # EDSM setting
this.apikey_label.grid(row=12, padx=PADX, sticky=tk.W)
this.apikey = nb.Entry(frame)
this.apikey.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
prefs_cmdr_changed(cmdr, is_beta)
return frame
示例11: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def __init__(self, text, regexp=False, nocase=False):
self.text = text
self.pattern = tkinter.StringVar()
self.regexp = tkinter.IntVar(int(regexp))
self.nocase = tkinter.IntVar(int(nocase))
self.prev_pattern = ""
self.prev_regexp = regexp
self.prev_nocase = nocase
self.findings = []
self.current = -1
self.text.tag_config("search", background='yellow', foreground="black")
bold_font = Font(self.text)
bold_font.configure(weight="bold")
self.text.tag_config("search_current", font=bold_font)
示例12: match_text
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def match_text(self, pattern, tag_proc, regexp=True):
text = self.text
text.mark_set('matchPos', '1.0')
count = tk.IntVar()
while True:
match_index = text.search(pattern, 'matchPos', count=count, regexp=regexp, stopindex='end')
if not match_index:
break
end_index = text.index( "%s+%sc" % (match_index, count.get()) )
text.mark_set('matchPos', end_index)
if callable(tag_proc):
tag_proc(match_index, end_index, text.get(match_index, end_index))
else:
text.tag_add(tag_proc, match_index, end_index)
示例13: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
"""Construct an horizontal LabeledScale with parent master, a
variable to be associated with the Ttk Scale widget and its range.
If variable is not specified, a Tkinter.IntVar is created.
WIDGET-SPECIFIC OPTIONS
compound: 'top' or 'bottom'
Specifies how to display the label relative to the scale.
Defaults to 'top'.
"""
self._label_top = kw.pop('compound', 'top') == 'top'
Frame.__init__(self, master, **kw)
self._variable = variable or Tkinter.IntVar(master)
self._variable.set(from_)
self._last_valid = from_
self.label = Label(self)
self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
self.scale.bind('<<RangeChanged>>', self._adjust)
# position scale and label according to the compound option
scale_side = 'bottom' if self._label_top else 'top'
label_side = 'top' if scale_side == 'bottom' else 'bottom'
self.scale.pack(side=scale_side, fill='x')
tmp = Label(self).pack(side=label_side) # place holder
self.label.place(anchor='n' if label_side == 'top' else 's')
# update the label as scale or variable changes
self.__tracecb = self._variable.trace_variable('w', self._adjust)
self.bind('<Configure>', self._adjust)
self.bind('<Map>', self._adjust)
示例14: test_widget_destroy
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def test_widget_destroy(self):
# automatically created variable
x = ttk.LabeledScale()
var = x._variable._name
x.destroy()
self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, var)
# manually created variable
myvar = Tkinter.DoubleVar()
name = myvar._name
x = ttk.LabeledScale(variable=myvar)
x.destroy()
self.assertEqual(x.tk.globalgetvar(name), myvar.get())
del myvar
self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, name)
# checking that the tracing callback is properly removed
myvar = Tkinter.IntVar()
# LabeledScale will start tracing myvar
x = ttk.LabeledScale(variable=myvar)
x.destroy()
# Unless the tracing callback was removed, creating a new
# LabeledScale with the same var will cause an error now. This
# happens because the variable will be set to (possibly) a new
# value which causes the tracing callback to be called and then
# it tries calling instance attributes not yet defined.
ttk.LabeledScale(variable=myvar)
if hasattr(sys, 'last_type'):
self.assertFalse(sys.last_type == Tkinter.TclError)
示例15: test_invoke
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import IntVar [as 别名]
def test_invoke(self):
success = []
def cb_test():
success.append(1)
return "cb test called"
myvar = Tkinter.IntVar()
cbtn = ttk.Radiobutton(command=cb_test, variable=myvar, value=0)
cbtn2 = ttk.Radiobutton(command=cb_test, variable=myvar, value=1)
res = cbtn.invoke()
self.assertEqual(res, "cb test called")
self.assertEqual(cbtn['value'], myvar.get())
self.assertEqual(myvar.get(),
cbtn.tk.globalgetvar(cbtn['variable']))
self.assertTrue(success)
cbtn2['command'] = ''
res = cbtn2.invoke()
self.assertEqual(res, '')
self.assertFalse(len(success) > 1)
self.assertEqual(cbtn2['value'], myvar.get())
self.assertEqual(myvar.get(),
cbtn.tk.globalgetvar(cbtn['variable']))
self.assertEqual(str(cbtn['variable']), str(cbtn2['variable']))