本文整理汇总了Python中tkinter.Label方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Label方法的具体用法?Python tkinter.Label怎么用?Python tkinter.Label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, text="IPSUM DOLOREM", pos="BR"):
self.text = text
self.pos = pos
self.fg = "black"
self.bg = "#f1f2f2" # default transparent color
self.width = 0
self.height = 0
tk = tkinter.Tk()
self.label = tkinter.Label(tk, anchor="w")
self.label.config(font=("Consolas", 8))
self.label.master.overrideredirect(True)
self.label.master.lift()
self.label.master.wm_attributes("-topmost", True)
self.label.master.wm_attributes("-disabled", True)
self.label.master.wm_attributes("-transparentcolor", "#f1f2f3")
hWindow = pywintypes.HANDLE(int(self.label.master.frame(), 16))
exStyle = win32con.WS_EX_COMPOSITED | win32con.WS_EX_LAYERED | win32con.WS_EX_NOACTIVATE | \
win32con.WS_EX_TOPMOST | win32con.WS_EX_TRANSPARENT
win32api.SetWindowLong(hWindow, win32con.GWL_EXSTYLE, exStyle)
self.label.pack()
self.update()
示例2: popup
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def popup(self, window, title, image, text, button_text, end_command=None):
popup = tk.Toplevel(window)
popup.resizable(False, False)
if MAIN_ICON != None:
if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
dummy = None
#popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
else:
popup.iconbitmap(MAIN_ICON)
popup.wm_title(title)
popup.tkraise(window)
def run_end():
popup.destroy()
if end_command != None:
end_command()
picture_label = tk.Label(popup, image=image)
picture_label.photo = image
picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
popup.wait_visibility()
popup.grab_set()
popup.wait_window()
示例3: video_invite_window
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def video_invite_window(message, inviter_name):
invite_window = tkinter.Toplevel()
invite_window.geometry('300x100')
invite_window.title('Invitation')
label1 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text=inviter_name)
label1.pack()
label2 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text='invites you to video chat!')
label2.pack()
def accept_invite():
invite_window.destroy()
video_accept(message[message.index('INVITE') + 6:])
def refuse_invite():
invite_window.destroy()
Refuse = tkinter.Button(invite_window, text="Refuse", command=refuse_invite)
Refuse.place(x=60, y=60, width=60, height=25)
Accept = tkinter.Button(invite_window, text="Accept", command=accept_invite)
Accept.place(x=180, y=60, width=60, height=25)
示例4: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, master=None, store_name=None, **kwargs):
super(FileBrowse, self).__init__(master=master, **kwargs)
self.label_text = tk.StringVar()
btn = tk.Button(self, text="下载到", command=self.choose_file)
btn.pack(
side=tk.LEFT,
)
tk.Label(self, textvariable=self.label_text).pack(
side=tk.LEFT,
fill=tk.X,
)
self.pack(fill=tk.X)
self._store_name = store_name
if store_name is not None:
self._config = config_store
save_path = self._config.op_read_path(store_name) or get_working_dir()
else:
self._config = None
save_path = get_working_dir()
self.label_text.set(
save_path
)
示例5: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self):
super().__init__()
self.title("Hello Tkinter")
self.label_text = tk.StringVar()
self.label_text.set("My Name Is: ")
self.name_text = tk.StringVar()
self.label = tk.Label(self, textvar=self.label_text)
self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=10)
self.name_entry = tk.Entry(self, textvar=self.name_text)
self.name_entry.pack(fill=tk.BOTH, expand=1, padx=20, pady=20)
hello_button = tk.Button(self, text="Say Hello", command=self.say_hello)
hello_button.pack(side=tk.LEFT, padx=(20, 0), pady=(0, 20))
goodbye_button = tk.Button(self, text="Say Goodbye", command=self.say_goodbye)
goodbye_button.pack(side=tk.RIGHT, padx=(0, 20), pady=(0, 20))
示例6: build
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def build(self, property_dict):
for c in self.interior.winfo_children():
c.destroy()
# Filter property dict
property_dict = {k: v for k, v in property_dict.items()
if self._key_filter_function(k)}
# Prettify key/value pairs for display
property_dict = {self._make_key_pretty(k): self._make_value_pretty(v)
for k, v in property_dict.items()}
# Sort by key and filter
dict_values = sorted(property_dict.items(), key=lambda x: x[0])
for n,(k,v) in enumerate(dict_values):
tk.Label(self.interior, text=k, borderwidth=1, relief=tk.SOLID,
wraplength=75, anchor=tk.E, justify=tk.RIGHT).grid(
row=n, column=0, sticky='nesw', padx=1, pady=1, ipadx=1)
tk.Label(self.interior, text=v, borderwidth=1,
wraplength=125, anchor=tk.W, justify=tk.LEFT).grid(
row=n, column=1, sticky='nesw', padx=1, pady=1, ipadx=1)
示例7: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, main_window, msg='Please enter a node:'):
tk.Toplevel.__init__(self)
self.main_window = main_window
self.title('Node Entry')
self.geometry('170x160')
self.rowconfigure(3, weight=1)
tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2,
sticky='NESW',padx=5,pady=5)
self.posibilities = [d['dataG_id'] for n,d in
main_window.canvas.dispG.nodes_iter(data=True)]
self.entry = AutocompleteEntry(self.posibilities, self)
self.entry.bind('<Return>', lambda e: self.destroy(), add='+')
self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5)
tk.Button(self, text='Ok', command=self.destroy).grid(
row=3, column=0, sticky='ESW',padx=5,pady=5)
tk.Button(self, text='Cancel', command=self.cancel).grid(
row=3, column=1, sticky='ESW',padx=5,pady=5)
# Make modal
self.winfo_toplevel().wait_window(self)
示例8: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, image, initialField, initialText):
frm = tk.Frame(root)
frm.config(background="white")
self.image = tk.PhotoImage(format='gif',data=images[image.upper()])
self.imageDimmed = tk.PhotoImage(format='gif',data=images[image])
self.img = tk.Label(frm)
self.img.config(borderwidth=0)
self.img.pack(side = "left")
self.fld = tk.Text(frm, **fieldParams)
self.initScrollText(frm,self.fld,initialField)
frm = tk.Frame(root)
self.txt = tk.Text(frm, **textParams)
self.initScrollText(frm,self.txt,initialText)
for i in range(2):
self.txt.tag_config(colors[i], background = colors[i])
self.txt.tag_config("emph"+colors[i], foreground = emphColors[i])
示例9: updateImageCount
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def updateImageCount(happyCount, sadCount):
global HCount, SCount, imageCountString, countString # Updating only when called by smileCallback/noSmileCallback
if happyCount is True and HCount < 400:
HCount += 1
if sadCount is True and SCount < 400:
SCount += 1
if HCount == 400 or SCount == 400:
HCount = 0
SCount = 0
# --- Updating Labels
# -- Main Count
imageCountPercentage = str(float((trainer.index + 1) * 0.25)) \
if trainer.index+1 < len(faces.images) else "Classification DONE! 100"
imageCountString = "Image Index: " + str(trainer.index+1) + "/400 " + "[" + imageCountPercentage + " %]"
labelVar.set(imageCountString) # Updating the Label (ImageCount)
# -- Individual Counts
countString = "(Happy: " + str(HCount) + " " + "Sad: " + str(SCount) + ")\n"
countVar.set(countString)
示例10: ShowMol
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', **kwargs):
""" Generates a picture of a molecule and displays it in a Tkinter window
"""
global tkRoot, tkLabel, tkPI
try:
import Tkinter
except ImportError:
import tkinter as Tkinter
try:
import ImageTk
except ImportError:
from PIL import ImageTk
img = MolToImage(mol, size, kekulize, wedgeBonds, **kwargs)
if not tkRoot:
tkRoot = Tkinter.Tk()
tkRoot.title(title)
tkPI = ImageTk.PhotoImage(img)
tkLabel = Tkinter.Label(tkRoot, image=tkPI)
tkLabel.place(x=0, y=0, width=img.size[0], height=img.size[1])
else:
tkPI.paste(img)
tkRoot.geometry('%dx%d' % (img.size))
示例11: add_attr
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def add_attr(self, attr_name, right_label_text=None, *args):
'''Add attr to the lower frame with a '-' button & title
attr_name: title to be shown on the left side
right_label_text: label string to be shown on the right side, which is
a word count or 'Calculating...'
'''
if len(self.attrs) == 0:
self.lower_frame = Frame(self)
self.lower_frame.pack(side="bottom", fill="both")
attr = LabeledFrame(self.lower_frame, title=attr_name)
btn_add_file = Tk.Button(attr, text=' - ')
btn_add_file.pack(fill="both", side="left", padx=10, pady=5)
btn_add_file.bind("<ButtonRelease-1>", partial(self.on_remove_attr, attr))
lb_base_files = Tk.Label(attr, text=attr_name)
lb_base_files.pack(fill="both", side="left", padx=10, pady=10)
if right_label_text is not None:
attr.right_label = Tk.Label(attr, text=right_label_text, font=('Helvetica', '10', 'italic'))
attr.right_label.pack(fill="both", side="right", padx=10, pady=10)
else:
attr.right_label = None
attr.pack(side="top", fill="both")
self.attrs.append(attr)
示例12: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter 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)
示例13: draw_board
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def draw_board(self, board):
self.piece_images.clear()
self.move_images = []
pieces = board.pieces
for (x, y) in pieces.keys():
self.piece_images[x, y] = tkinter.PhotoImage(file=pieces[x, y].get_image_file_name())
self.can.create_image(board_coord(x), board_coord(y), image=self.piece_images[x, y])
if board.selected_piece:
for (x, y) in board.selected_piece.get_move_locs(board):
self.move_images.append(tkinter.PhotoImage(file="images/OOS.gif"))
self.can.create_image(board_coord(x), board_coord(y), image=self.move_images[-1])
# self.can.create_text(board_coord(x), board_coord(y),text="Hello")
# label = tkinter.Label(self.root, text='Hello world!')
# label.place(x=30,y=30)
# label.pack(fill='x', expand=1)
示例14: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, loginQueue):
tk.Toplevel.__init__(self)
self.configure(pady=10, padx=20)
self.wm_attributes("-topmost", True)
self.wm_title("PyEveLiveDPS Awaiting Login")
try:
self.iconbitmap(sys._MEIPASS + '\\app.ico')
except Exception:
try:
self.iconbitmap("app.ico")
except Exception:
pass
self.geometry("200x50")
self.update_idletasks()
tk.Label(self, text='Waiting for you to login...').grid(row=1, column=1)
self.loginStatus = loginQueue.get()
self.destroy()
示例15: addLine
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def addLine(self, settingsList, dpsFrame):
lineNumber = len(settingsList)
settingsList.append({"transitionValue": "", "color": "#FFFFFF"})
settingsList[lineNumber]["transitionValue"] = tk.StringVar()
settingsList[lineNumber]["transitionValue"].set(str(100*lineNumber))
removeButton = tk.Button(dpsFrame, text="X", command=lambda:self.removeLine(lineNumber, settingsList, dpsFrame))
font = tkFont.Font(font=removeButton['font'])
font.config(weight='bold')
removeButton['font'] = font
removeButton.grid(row=lineNumber, column="0")
lineLabel = tk.Label(dpsFrame, text="Threshold when the line changes color:")
lineLabel.grid(row=lineNumber, column="1")
initialThreshold = tk.Entry(dpsFrame, textvariable=settingsList[lineNumber]["transitionValue"], width=10)
initialThreshold.grid(row=lineNumber, column="2")
initialLabel = tk.Label(dpsFrame, text="Color:")
initialLabel.grid(row=lineNumber, column="3")
colorButton = tk.Button(dpsFrame, text=" ",
command=lambda:self.colorWindow(settingsList[lineNumber], colorButton),
bg=settingsList[lineNumber]["color"])
colorButton.grid(row=lineNumber, column="4")