本文整理汇总了Python中tkinter.ttk.Label方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Label方法的具体用法?Python ttk.Label怎么用?Python ttk.Label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk
的用法示例。
在下文中一共展示了ttk.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_friends
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def load_friends(self):
all_users = self.requester.get_all_users()
for user in all_users:
if user['username'] != self.username:
friend_frame = ttk.Frame(self.canvas_frame)
profile_photo = tk.PhotoImage(file="images/avatar.png")
profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
profile_photo_label.image = profile_photo
friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)
message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"])
message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend)
profile_photo_label.pack(side=tk.LEFT)
friend_name.pack(side=tk.LEFT)
message_button.pack(side=tk.RIGHT)
friend_frame.pack(fill=tk.X, expand=1)
示例2: load_friends
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def load_friends(self):
friend_frame = ttk.Frame(self.canvas_frame)
profile_photo = tk.PhotoImage(file="images/avatar.png")
profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
profile_photo_label.image = profile_photo
friend_name = ttk.Label(friend_frame, text="Jaden Corebyn", anchor=tk.W)
message_button = ttk.Button(friend_frame, text="Chat", command=self.open_chat_window)
profile_photo_label.pack(side=tk.LEFT)
friend_name.pack(side=tk.LEFT)
message_button.pack(side=tk.RIGHT)
friend_frame.pack(fill=tk.X, expand=1)
示例3: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __init__(self, master):
super().__init__()
self.master = master
self.transient(master)
self.title("Change Avatar")
self.geometry("350x200")
self.image_file_types = [
("Png Images", ("*.png", "*.PNG")),
]
self.current_avatar_image = tk.PhotoImage(file=avatar_file_path)
self.current_avatar = ttk.Label(self, image=self.current_avatar_image)
choose_file_button = ttk.Button(self, text="Choose File", command=self.choose_image)
self.current_avatar.pack()
choose_file_button.pack()
示例4: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __init__(self, master):
self.master = master
self.notebk = ttk.Notebook(self.master)
self.notebk.pack()
self.frame1 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
self.frame2 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
self.notebk.add(self.frame1, text = 'One')
self.notebk.add(self.frame2, text = 'Two')
self.btn = ttk.Button(self.frame1, text='Add/Insert Tab at Position 1', command = self.AddTab)
self.btn.pack()
self.btn2 = ttk.Button(self.frame1, text='Disable Tab at Position 1', command = self.disableTab)
self.btn2.pack()
strdisplay = r'Tab ID:{}'.format(self.notebk.select())
ttk.Label(self.frame1, text = strdisplay).pack()
strdisplay2 = 'Tab index:{}'.format(self.notebk.index(self.notebk.select()))
ttk.Label(self.frame1, text = strdisplay2).pack()
示例5: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __init__(self, master): # constructor method
# define list of label texts
self.greet_list = ('Hello, World! This is python GUI.', \
'Hello, This is Python GUI. Sadly, I was made to say Hello only. I will love to say so much more.')
# creat label as a child of root window with some text.
self.label = ttk.Label(master, text = self.greet_list[0])
self.btn = ttk.Button(master, text = 'Greet Again', command = self.handle_text) # create a button
# store image in the label obj to keep it in the scope as
# long as label is displayed and to avoid getting the image getting garbage collected
imgpath = 'simple_gif.gif' # path of the image
self.label.img = tk.PhotoImage(file = imgpath) # read_image :: saving image within label_object to prevent its garbage collection
self.label.config(image = self.label.img) # display image in label widget
self.label.config(compound = 'left') # to display image in left of text
self.label.pack() # pack label to the window with pack() geometry method of Label
self.btn.pack()
self.label.config(wraplength = 200) # specify wraplength of text in label
self.label.config(justify = tk.CENTER) # justify text in label to (CENTER, RIGHT or LEFT)
self.label.config(foreground = 'blue', background = 'yellow') # insert font color (foreground) and background color
self.label.config(font = ('Times', 10, 'bold')) # font = (font_name, font_size, font_type)
示例6: combineAction
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def combineAction():
global course_json
other_course_dir = tk.filedialog.askdirectory(initialdir = ".", title = "Select second course directory")
if other_course_dir:
drawPlaceholder()
course1_json = copy.deepcopy(course_json) # Make copy so this isn't "permanent" in memory
course2_json = tgc_tools.get_course_json(other_course_dir)
course1_json = tgc_tools.merge_courses(course1_json, course2_json)
drawCourse(course1_json)
popup = tk.Toplevel()
popup.geometry("400x400")
popup.wm_title("Confirm course merge?")
label = ttk.Label(popup, text="Confirm course merge?")
label.pack(side="top", fill="x", pady=10)
B1 = ttk.Button(popup, text="Yes, Merge", command = partial(confirmCourse, popup, course1_json))
B1.pack()
B2 = ttk.Button(popup, text="No, Abandon Merge", command = partial(confirmCourse, popup, None))
B2.pack()
popup.mainloop()
示例7: create_parameters_frame
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [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')
示例8: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.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)
示例9: create_statusbar
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def create_statusbar(self):
statusBar = ttk.Frame(self.master)
statusLabel = ttk.Label(statusBar, textvariable=self.statusText)
statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E))
self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
anchor=tk.CENTER)
self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1)
TkUtil.Tooltip.Tooltip(self.modifiedLabel,
text="MOD if the text has unsaved changes")
self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
anchor=tk.CENTER)
self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E),
pady=2, padx=1)
TkUtil.Tooltip.Tooltip(self.positionLabel,
text="Current line and column position")
ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E))
statusBar.columnconfigure(0, weight=1)
statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E))
self.set_status_text("Start typing to create a new document or "
"click File→Open")
示例10: create_toolbar
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def create_toolbar(self):
self.toolbar = ttk.Frame(self.master)
newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
image=self.images[NEW], command=self.board.new_game)
TkUtil.Tooltip.Tooltip(newButton, text="New Game")
zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
self.zoomSpinbox = Spinbox(self.toolbar,
textvariable=self.zoom, from_=Board.MIN_ZOOM,
to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
justify=tk.RIGHT, validate="all")
self.zoomSpinbox.config(validatecommand=(
self.zoomSpinbox.register(self.validate_int), "%P"))
TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
textvariable=self.shapeName, state="readonly",
values=sorted(Shapes.ShapeForName.keys()))
TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
zoomLabel, self.zoomSpinbox, self.shapeCombobox))
self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board)
示例11: show
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def show(self):
self.leave()
self.tip = tk.Toplevel(self.master)
self.tip.withdraw() # Don't show until we have the geometry
self.tip.wm_overrideredirect(True) # No window decorations etc.
if TkUtil.mac():
self.tip.tk.call("::tk::unsupported::MacWindowStyle",
"style", self.tip._w, "help", "none")
label = ttk.Label(self.tip, text=self.text, padding=1,
background=self.background, wraplength=480,
relief=None if TkUtil.mac() else tk.GROOVE,
font=tkfont.nametofont("TkTooltipFont"))
label.pack()
x, y = self.position()
self.tip.wm_geometry("+{}+{}".format(x, y))
self.tip.deiconify()
if self.master.winfo_viewable():
self.tip.transient(self.master)
self.tip.update_idletasks()
self.timerId = self.master.after(self.showTime, self.hide)
示例12: __create_widgets
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __create_widgets(self):
self.dockFrame = ttk.Frame(self, relief=tk.RAISED, padding=PAD)
self.dockLeftButton = ttk.Button(self.dockFrame,
image=self.images[DOCKLEFT], style="Toolbutton",
command=self.dock_left)
TkUtil.Tooltip.Tooltip(self.dockLeftButton, text="Dock Left")
self.dockRightButton = ttk.Button(self.dockFrame,
image=self.images[DOCKRIGHT], style="Toolbutton",
command=self.dock_right)
TkUtil.Tooltip.Tooltip(self.dockRightButton, text="Dock Right")
self.dockLabel = ttk.Label(self.dockFrame, text=self.title,
anchor=tk.CENTER)
TkUtil.Tooltip.Tooltip(self.dockLabel, text="Drag and drop to "
"dock elsewhere or to undock")
self.undockButton = ttk.Button(self.dockFrame,
image=self.images[UNDOCK], style="Toolbutton",
command=self.undock)
TkUtil.Tooltip.Tooltip(self.undockButton, text="Undock")
self.hideButton = ttk.Button(self.dockFrame,
image=self.images[HIDE], style="Toolbutton",
command=lambda *args: self.visible.set(False))
TkUtil.Tooltip.Tooltip(self.hideButton, text="Hide")
self.create_widgets()
示例13: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __init__(self, parent, label='', input_class=ttk.Entry,
input_var=None, input_args=None, label_args=None,
**kwargs):
super().__init__(parent, **kwargs)
input_args = input_args or {}
label_args = label_args or {}
self.variable = input_var
if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
input_args["text"] = label
input_args["variable"] = input_var
else:
self.label = ttk.Label(self, text=label, **label_args)
self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
input_args["textvariable"] = input_var
self.input = input_class(self, **input_args)
self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
self.columnconfigure(0, weight=1)
self.error = getattr(self.input, 'error', tk.StringVar())
self.error_label = ttk.Label(self, textvariable=self.error)
self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))
示例14: body
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def body(self, parent):
lf = tk.Frame(self)
ttk.Label(lf, text='Login to ABQ',
font='TkHeadingFont').grid(row=0)
ttk.Style().configure('err.TLabel',
background='darkred', foreground='white')
if self.error.get():
ttk.Label(lf, textvariable=self.error,
style='err.TLabel').grid(row=1)
ttk.Label(lf, text='User name:').grid(row=2)
self.username_inp = ttk.Entry(lf, textvariable=self.user)
self.username_inp.grid(row=3)
ttk.Label(lf, text='Password:').grid(row=4)
self.password_inp = ttk.Entry(lf, show='*', textvariable=self.pw)
self.password_inp.grid(row=5)
lf.pack()
return self.username_inp
示例15: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Label [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("ABQ Data Entry Application")
self.resizable(width=False, height=False)
ttk.Label(
self,
text="ABQ Data Entry Application",
font=("TkDefaultFont", 16)
).grid(row=0)
self.recordform = v.DataRecordForm(self, m.CSVModel.fields)
self.recordform.grid(row=1, padx=10)
self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
self.savebutton.grid(sticky="e", row=2, padx=10)
# status bar
self.status = tk.StringVar()
self.statusbar = ttk.Label(self, textvariable=self.status)
self.statusbar.grid(sticky="we", row=3, padx=10)
self.records_saved = 0