本文整理汇总了Python中ttk.Label方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Label方法的具体用法?Python ttk.Label怎么用?Python ttk.Label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk
的用法示例。
在下文中一共展示了ttk.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def __init__(self, root, resource_dir, lang="fr"):
ttk.Frame.__init__(self, root)
self.resource_dir = resource_dir
self._lang = None
langs = os.listdir(os.path.join(self.resource_dir, "master"))
if langs:
self._lang = (lang if lang in langs else langs[0])
self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
self.items.sort(key=lambda x: x.lower())
max_length = max([len(item) for item in self.items])
self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
#strVar = tkinter.StringVar()
self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)
for item in self.items:
self.masters.insert(tkinter.END, item)
示例2: test_sashpos
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def test_sashpos(self):
self.assertRaises(Tkinter.TclError, self.paned.sashpos, None)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, '')
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
child = ttk.Label(self.paned, text='a')
self.paned.add(child, weight=1)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
child2 = ttk.Label(self.paned, text='b')
self.paned.add(child2)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
self.paned.wait_visibility()
curr_pos = self.paned.sashpos(0)
self.paned.sashpos(0, 1000)
self.assertTrue(curr_pos != self.paned.sashpos(0))
self.assertTrue(isinstance(self.paned.sashpos(0), int))
示例3: test_sashpos
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def test_sashpos(self):
self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child = ttk.Label(self.paned, text='a')
self.paned.add(child, weight=1)
self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child2 = ttk.Label(self.paned, text='b')
self.paned.add(child2)
self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
self.paned.wait_visibility()
curr_pos = self.paned.sashpos(0)
self.paned.sashpos(0, 1000)
self.assertNotEqual(curr_pos, self.paned.sashpos(0))
self.assertIsInstance(self.paned.sashpos(0), int)
示例4: toggle_empty_state
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def toggle_empty_state(self, show, addRow=True):
if (show):
self.root.minsize(width=0, height=260)
self.root.maxsize(width=1200, height=260)
self.emptyStateButton = ttk.Button(self.mainPluginFrame, text="Add Plugin Options", command=lambda: self.toggle_empty_state(False))
self.emptyStateButton.grid(column=0, row=0, sticky=(N,W,E,S))
if self.showingHeader:
self.headerLabel.destroy()
self.addButton.destroy()
self.generateButton.destroy()
else:
self.root.minsize(width=0, height=380)
self.root.maxsize(width=1200, height=380)
self.showingHeader = True
self.headerLabel = ttk.Label(self.mainPluginFrame, text="Plugin Options")
self.headerLabel.grid(column=0, row=0, sticky=(N,W), pady=(0, 15))
self.addButton = ttk.Button(self.mainPluginFrame, text='Add Plugin Option', command=self.add_plugin_option)
self.addButton.grid(column=1, row=0, sticky=(N,E))
self.generateButton = ttk.Button(self.mainPluginFrame, text='Generate Header', command=self.generate_plugin_options_header)
self.generateButton.grid(column=2, row=0, sticky=(N,E))
if self.emptyStateButton:
if addRow:
self.add_plugin_option()
self.emptyStateButton.destroy()
示例5: de_widget
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def de_widget(self):
# Initialize widget
self.init_widget()
# strategy
self.strategy_label = ttk.Label(self.frame1.sliders, text = "Strategy")
self.strategy_option_menu = ttk.OptionMenu(self.frame1.sliders, self.strategy, self.strategy.get(),
*sorted(self.STRATOPT))
self.strategy_label.place(relx = 0, x = 0, y = 5, anchor = "nw")
self.strategy_option_menu.place(relx = 0, x = 70, y = 3, anchor = "nw")
# CR
self._label("Crossover probability", 2)
self._scale(0., 1., 0.01, self.CR, 2)
self._entry(self.CR, 2)
# F
self._label("Differential weight", 4)
self._scale(0., 2., 0.01, self.F, 4)
self._entry(self.F, 4)
示例6: initialize
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def initialize(self):
"""
Set window layout.
"""
self.grid()
self.respond = ttk.Button(self, text='Get Response', command=self.get_response)
self.respond.grid(column=0, row=0, sticky='nesw', padx=3, pady=3)
self.usr_input = ttk.Entry(self, state='normal')
self.usr_input.grid(column=1, row=0, sticky='nesw', padx=3, pady=3)
self.conversation_lbl = ttk.Label(self, anchor=tk.E, text='Conversation:')
self.conversation_lbl.grid(column=0, row=1, sticky='nesw', padx=3, pady=3)
self.conversation = ScrolledText.ScrolledText(self, state='disabled')
self.conversation.grid(column=0, row=2, columnspan=2, sticky='nesw', padx=3, pady=3)
示例7: body
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def body(self, master):
"""
Generates the required text listing all elements that will be deleted.
Displays the "OK" and "Cancel" buttons.
"""
if len(self.id_tuples) == 0:
message_string = "No elements selected."
elif len(self.id_tuples) == 1:
message_string = 'Delete "{}"?'.format(
self.tree.get_element(self.id_tuples[0][0]).name
)
else:
message_string = "Delete the following items?\n"
for x, level in self.id_tuples:
if level == 0:
bullet = " " + u"\u25C6"
else:
bullet = " " * (level + 1) + u"\u25C7"
message_string += u"{bullet} {name}\n".format(
bullet=bullet, name=self.tree.get_element(x).name
)
message = ttk.Label(master, text=message_string, justify="left")
message.grid(row=0, sticky="w")
示例8: body
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def body(self, master):
"""
Generates the required text listing all SeqLibs that will have their FASTQ options updated.
Displays the "OK" and "Cancel" buttons.
"""
if len(self.target_ids) == 0:
message_string = "No elegible SeqLibs selected."
elif len(self.target_ids) == 1:
message_string = 'Apply FASTQ filtering options from "{}" to "{}"?'.format(
self.tree.get_element(self.source_id).name,
self.tree.get_element(self.target_ids[0]).name,
)
else:
bullet = " " + u"\u25C6"
message_string = 'Apply FASTQ filtering options from "{}"" to the following?\n'.format(
self.tree.get_element(self.source_id).name
)
for x in self.target_ids:
message_string += u"{bullet} {name}\n".format(
bullet=bullet, name=self.tree.get_element(x).name
)
message = ttk.Label(master, text=message_string, justify="left")
message.grid(row=0, sticky="w")
示例9: test_tooltip
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def test_tooltip(self):
t = Tooltip(self.window, text='Hi!', style='my.TLabel', alpha=0.5)
self.window.update()
self.assertEqual(t.keys(), ['alpha'] + ttk.Label().keys())
self.assertEqual(str(t.cget('compound')), 'left')
self.assertEqual(t.cget('text'), 'Hi!')
self.assertEqual(t.cget('alpha'), 0.5)
self.assertEqual(t.cget('style'), 'my.TLabel')
t.configure(text='Hello', style='test.TLabel',
image=None, alpha=0.75, compound='right')
self.assertEqual(str(t.cget('compound')), 'right')
self.assertEqual(t.cget('text'), 'Hello')
self.assertEqual(t.cget('alpha'), 0.75)
self.assertEqual(t.cget('style'), 'test.TLabel')
self.assertEqual(t.cget('image'), '')
示例10: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def __init__(self, master):
tk.Frame.__init__(self, master)
self.pack(padx=20, pady=20)
self.master = master
self.selection = tk.StringVar()
self.selection.set('white')
tk.Label(self, text="These are radiobuttons").pack()
tk.Radiobutton(self, text='White', value='white', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Red', value='red', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Green', value='green', variable=self.selection, command=self.set_color).pack(anchor='w')
tk.Radiobutton(self, text='Blue', value='blue', variable=self.selection, command=self.set_color).pack(anchor='w')
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:20,代码来源:Tkinter_Widget_Examples.py
示例11: addpagerow
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def addpagerow(self, parent, content, align=None):
for i in range(len(content)):
label = nb.Label(parent, text=content[i])
if i == 0:
label.grid(padx=10, sticky=tk.W)
row = parent.grid_size()[1]-1
elif align is None and i == len(content) - 1: # Assumes last column right justified if unspecified
label.grid(row=row, column=i, padx=10, sticky=tk.E)
else:
label.grid(row=row, column=i, padx=10, sticky=align or tk.W)
示例12: tabchanged
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def tabchanged(self, event):
self.outvarchanged()
if platform == 'darwin':
# Hack to recompute size so that buttons show up under Mojave
notebook = event.widget
frame = self.nametowidget(notebook.winfo_parent())
temp = nb.Label(frame)
temp.grid()
temp.update_idletasks()
temp.destroy()
示例13: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def __init__(self, master=None, **kw):
self.url = 'url' in kw and kw.pop('url') or None
self.popup_copy = kw.pop('popup_copy', False)
self.underline = kw.pop('underline', None) # override ttk.Label's underline
self.foreground = kw.get('foreground') or 'blue'
self.disabledforeground = kw.pop('disabledforeground', ttk.Style().lookup('TLabel', 'foreground', ('disabled',))) # ttk.Label doesn't support disabledforeground option
if platform == 'darwin':
# Use tk.Label 'cos can't set ttk.Label background - http://www.tkdocs.com/tutorial/styles.html#whydifficult
kw['background'] = kw.pop('background', 'systemDialogBackgroundActive')
kw['anchor'] = kw.pop('anchor', tk.W) # like ttk.Label
tk.Label.__init__(self, master, **kw)
else:
ttk.Label.__init__(self, master, **kw)
self.bind('<Button-1>', self._click)
self.menu = tk.Menu(None, tearoff=tk.FALSE)
self.menu.add_command(label=_('Copy'), command = self.copy) # As in Copy and Paste
self.bind(platform == 'darwin' and '<Button-2>' or '<Button-3>', self._contextmenu)
self.bind('<Enter>', self._enter)
self.bind('<Leave>', self._leave)
# set up initial appearance
self.configure(state = kw.get('state', tk.NORMAL),
text = kw.get('text'),
font = kw.get('font', ttk.Style().lookup('TLabel', 'font')))
# Change cursor and appearance depending on state and text
示例14: preferences
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def preferences(self, event=None):
preferenceTop = tkinter.Toplevel()
preferenceTop.focus_set()
notebook = ttk.Notebook(preferenceTop)
frame1 = ttk.Frame(notebook)
notebook.add(frame1, text='general')
frame2 = ttk.Frame(notebook)
notebook.add(frame2, text='shortcuts')
c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word)
c.pack()
shortcuts_vars = []
shortcuts_gui = []
cur_row = 0
j = -1
frame_list = []
frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts"))
frame_list[-1].pack(fill="both", expand="yes")
for i, shortcut in enumerate(self.shortcuts):
j += 1
key, cmd, bindings = shortcut
name, command = cmd
shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key))
tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W)
entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j])
entry.grid(row=cur_row, column=1)
cur_row += 1
notebook.pack()
#
# ? menu methods
#
示例15: about_sem
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Label [as 别名]
def about_sem(self, event=None):
options = {"background":"white"}
aboutTop = tkinter.Toplevel(**options)
aboutTop.title("About SEM")
aboutTop.focus_set()
two_cols = []
two_cols.append(("author:", "Yoann Dupont"))
two_cols.append(("mail:", "yoa.dupont@gmail.com"))
two_cols.append(("website:", "http://www.lattice.cnrs.fr/sites/itellier/SEM.html"))
two_cols.append(("github:", "https://github.com/YoannDupont/SEM"))
two_cols.append(("online app:", "apps.lattice.cnrs.fr/sem"))
x = 0
label = ttk.Label(aboutTop, text=sem.full_name(), **options)
label.grid(row=x, column=0)
x += 1
ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
x += 1
ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
x += 1
for key, val in two_cols:
label = ttk.Label(aboutTop, text=key, **options)
label.grid(row=x, column=0, sticky="w")
label = ttk.Label(aboutTop, text=val, **options)
label.grid(row=x, column=1, sticky="w")
x += 1
ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
x += 1
#
# global methods
#