本文整理汇总了Python中tkinter.Label类的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent, frames, forks, wheelsets, groups, components):
"""
inicjalizacja obiektu okna - nieistotne dla idei zdania
"""
super(ConfigurationWindow, self).__init__(parent)
self._bike = None
self.parent = parent
self.frames = frames
self.forks = forks
self.wheelsets = wheelsets
self.groups = groups
self.components = components
self.parent.title("Bicycle configurator")
self._bike_price = StringVar(self.parent)
self._bike_weight = StringVar(self.parent)
self._bike_travel = StringVar(self.parent)
self.price_label = Label(self.parent, textvariable=self._bike_price)
self.weight_label = Label(self.parent, textvariable=self._bike_weight)
self.travel_label = Label(self.parent, textvariable=self._bike_travel)
self.createInterface()
self.createBike()
self.price_label.pack()
self.weight_label.pack()
self.travel_label.pack()
self.pack(fill=BOTH, expand=1)
示例2: __init__
def __init__(self, master=None):
# Avoiding to send it continuously.
self.lock = False
Frame.__init__(self, master)
self.grid()
self.master = master
# Setting for ComboBox.
self.url_lang_combobox_str = StringVar()
self.url_lang_combobox_list = lang_list
# UI components.
self.receiver_email_text = Label(self, text="Receiver:")
self.receiver_email_field = Entry(self, width=50)
self.subject_text = Label(self, text='Subject:')
self.subject_field = Entry(self, width=50)
self.receiver_name_text = Label(self, text='Name:')
self.receiver_name_field = Entry(self, width=50)
self.url_lang_text = Label(self, text='Link lang:')
self.url_lang_combobox = Combobox(self, textvariable=self.url_lang_combobox_str, values=self.url_lang_combobox_list, state='readonly')
self.send_progressbar = Progressbar(self, orient='horizontal', length=500, mode='determinate', maximum=300)
self.send_button = Button(self, text='Send', command=self._send_mail)
self.quit_button = Button(self, text='Exit', command=self.__exit)
self.log_msg_text = ScrolledText(self)
# Attachment.
self.mail_attachment_list = attachment_list[:]
self.url_lang_link_title = None
self.url_lang_link = copy.deepcopy(content_link)
# Mailer
self._mailer = None
# Let Mailer can control components.
Mailer.window_content = self
self.__create_widgets()
示例3: home_page
def home_page(self, master):
frame = Frame(master)
frame.grid(row=0, column=0)
image = PhotoImage(file="img/guido.gif")
bg = Label(frame, image=image)
bg.image = image
bg.grid(row=0, column=0, rowspan=4, columnspan=2)
index = 0
while index < 3:
frame.grid_columnconfigure(index, minsize=200)
frame.grid_rowconfigure(index, minsize=80)
index += 1
summary_button = HomeButton(frame, self.to_summary, 'img/summary.png')
summary_button.grid(row=0, column=0, sticky='w')
edit_button = HomeButton(frame, self.to_edit, 'img/edit.png')
edit_button.grid(row=0, column=1, sticky='e')
momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png')
momentary_button.grid(row=1, column=0, sticky='w')
preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png')
preferences_button.grid(row=1, column=1, sticky='e')
music = HomeButton(frame, self.to_summary, 'img/music.png')
music.grid(row=2, column=0, sticky='w')
info = HomeButton(frame, self.to_summary, 'img/info.png')
info.grid(row=2, column=1, sticky='e')
return frame
示例4: create_widgets
def create_widgets(self):
""" Login form """
frame_top = Frame(self, pady=15, padx=15)
frame_top.pack()
self.email = StringVar()
self.email_label = Label(frame_top, text="Email")
self.email_entry = Entry(frame_top, textvariable=self.email)
self.password = StringVar()
self.password_label = Label(frame_top, text="Password")
self.password_entry = Entry(frame_top,
textvariable=self.password, show='*')
frame_bottom = Frame(self, pady=15, padx=15)
frame_bottom.pack()
self.submit = Button(frame_bottom)
self.submit["text"] = "Login"
self.submit["command"] = self.sign_in
#layout widgets in grid
self.email_label.grid(row=1, column=0)
self.email_entry.grid(row=1, column=1)
self.password_label.grid(row=2, column=0)
self.password_entry.grid(row=2, column=1)
self.submit.grid(row=2, column=0)
示例5: __init__
def __init__(self, master):
self.top = Toplevel(master)
self.entry_width = 15
self.set_none_limits()
self.real_max_label = Label(self.top, text="Real Max: ")
self.real_min_label = Label(self.top, text="Real Min: ")
self.imag_max_label = Label(self.top, text="Imag Max: ")
self.imag_min_label = Label(self.top, text="Imag Min: ")
self.real_max_entry = Entry(self.top, width=self.entry_width)
self.real_min_entry = Entry(self.top, width=self.entry_width)
self.imag_max_entry = Entry(self.top, width=self.entry_width)
self.imag_min_entry = Entry(self.top, width=self.entry_width)
self.submit_button = Button(self.top, text="Submit", command=self.submit)
self.cancel_button = Button(self.top, text="Cancel", command=self.top.destroy)
self.real_max_label.grid(row=0, column=0)
self.real_min_label.grid(row=1, column=0)
self.imag_max_label.grid(row=2, column=0)
self.imag_min_label.grid(row=3, column=0)
self.real_max_entry.grid(row=0, column=1)
self.real_min_entry.grid(row=1, column=1)
self.imag_max_entry.grid(row=2, column=1)
self.imag_min_entry.grid(row=3, column=1)
self.submit_button.grid(row=4, column=0)
self.cancel_button.grid(row=4, column=1)
self.top.bind("<Return>", self.submit)
self.top.bind("<Escape>", self.top.destroy)
self.real_max_entry.focus()
示例6: display_image
def display_image(title,image):
win = Toplevel(root)
photo = ImageTk.PhotoImage(image)
win.title(title)
label = Label(win,image=photo)
label.image = photo #Kludge: keep a reference to avoid garbage collection!
label.pack()
示例7: _initfilepanel
def _initfilepanel(self):
frame = Frame(self)
frame.grid(row=0, column=0, sticky=E + W + S + N)
label = Label(frame, text="File List: ")
label.grid(sticky=N + W)
self.filelist = Listbox(frame, width=40)
self.filelist.grid(row=1, column=0, rowspan=2, columnspan=3)
vsl = Scrollbar(frame, orient=VERTICAL)
vsl.grid(row=1, column=3, rowspan=2, sticky=N + S + W)
hsl = Scrollbar(frame, orient=HORIZONTAL)
hsl.grid(row=3, column=0, columnspan=3, sticky=W + E + N)
self.filelist.config(yscrollcommand=vsl.set, xscrollcommand=hsl.set)
self.filelist.bind('<<ListboxSelect>>', self._onfilelistselection)
hsl.config(command=self.filelist.xview)
vsl.config(command=self.filelist.yview)
upbtn = Button(frame, text="Up", width=7, command=self._upfile)
upbtn.grid(row=1, column=4, padx=5, pady=5)
downbtn = Button(frame, text="Down", width=7, command=self._downfile)
downbtn.grid(row=2, column=4, padx=5, pady=5)
newbtn = Button(frame, text="New", width=7, command=self._addfile)
newbtn.grid(row=4, column=1, pady=5, sticky=E + S)
delbtn = Button(frame, text="Delete", width=7, command=self._deletefile)
delbtn.grid(row=4, column=2, padx=5, pady=5, sticky=W + S)
示例8: __init__
def __init__(self, master):
"""
Establish the GUI of this popup
"""
BuilderPopup.__init__(self, master)
self.data = (0, 0, 0)
self.radius = Label(self.top, text="Radius")
self.radius_entry = Entry(self.top, width=self.width, bd=self.bd)
self.n_circles_entry = Entry(self.top, width=self.width, bd=self.bd)
self.n_circles_label = Label(self.top, text="Number of circles")
self.center = Label(self.top, text="Center")
self.center_entry = Entry(self.top, width=self.width, bd=self.bd)
self.spindles = Label(self.top, text="Number of \"Roots\"")
self.spindles_entry = Entry(self.top, width=self.width, bd=self.bd)
self.build_spindle_submit = Button(self.top, text="Build!", command=self.cleanup)
self.top.bind("<Return>", self.cleanup)
self.radius.grid(row=0, column=0)
self.radius_entry.grid(row=0, column=1)
self.n_circles_label.grid(row=1, column=0)
self.n_circles_entry.grid(row=1, column=1)
self.center.grid(row=2, column=0)
self.center_entry.grid(row=2, column=1)
self.spindles_entry.grid(row=3, column=1)
self.spindles.grid(row=3, column=0)
self.build_spindle_submit.grid(row=4, column=0, columnspan=2)
self.top_left = 0
self.bottom_right = 0
self.radius_entry.focus()
示例9: ProgramWidget
class ProgramWidget(Frame):
def __init__(self, parent, client):
super(ProgramWidget, self).__init__(parent)
self.client = client
self.client.onProgramChange = self.programChanged
self.programLabel = Label(self, text = 'Program:')
self.programLabel.grid(row = 0, column = 0)
self.programEntry = Entry(self, text = 'Program name',
state = 'readonly')
self.programEntry.grid(row = 0, column = 1)
self.buttonPanel = Frame(self)
self.buttonPanel.grid(row = 1, column = 0, columnspan = 2, sticky = W)
self.newButton = Button(self.buttonPanel, text='New',
command = self.newProgram)
self.newButton.pack(side = LEFT)
def programChanged(self):
self.__setProgramText(str(self.client.state))
def __setProgramText(self, text):
self.programEntry.configure(state = NORMAL)
self.programEntry.delete(0)
self.programEntry.insert(0, text)
self.programEntry.configure(state = 'readonly')
def newProgram(self):
self.client.makeNewProgram()
示例10: CircleBuilderPopup
class CircleBuilderPopup(BuilderPopup):
"""
Class that launches a popup and collects user data to pass data back to the main window
to build a circle.
"""
def __init__(self, master):
"""
Establish the GUI of this popup
"""
BuilderPopup.__init__(self, master)
self.data = (0, 0)
self.radius = Label(self.top, text="Radius")
self.radius_entry = Entry(self.top, width=self.width, bd=self.bd)
self.center = Label(self.top, text="Center")
self.center_entry = Entry(self.top, width=self.width, bd=self.bd)
self.build_circle_submit = Button(self.top, text="Build!", command=self.cleanup)
self.top.bind("<Return>", self.cleanup)
self.radius.grid(row=0, column=0)
self.radius_entry.grid(row=0, column=1)
self.center.grid(row=1, column=0)
self.center_entry.grid(row=1, column=1)
self.build_circle_submit.grid(row=2, column=0, columnspan=2)
self.top_left = 0
self.bottom_right = 0
self.radius_entry.focus()
def cleanup(self, entry=None):
"""
Collect the data from the user and package it into object variables, then close.
"""
center = complex(0, 0)
if self.center_entry.get():
center = complex(allow_constants(self.center_entry.get()))
self.data = (float(allow_constants(self.radius_entry.get())), center)
self.top.destroy()
示例11: InfoWindow
class InfoWindow(Toplevel):
def __init__(self, master=None, text=None, textvariable=None, title=None,
font=tkinter.font.nametofont("TkHeadingFont"), **kw):
Toplevel.__init__(self, master, **kw)
self._window(master, title, text, textvariable, font)
def _window(self, master, title, text, textvariable, font):
title = title if title is not None else _("{prg}").format(prg=PROGNAME)
self.title(title)
self.protocol("WM_DELETE_WINDOW", self._doNotQuit)
self.resizable(width=False, height=False)
self.transient(master)
if text is not None:
kwargs = {"text": text}
else:
kwargs = {"textvariable": textvariable}
self.label = Label(self, borderwidth=20, font=font, **kwargs)
self.label.pack()
self.update_idletasks()
self.grab_set() # make the dialog modal
def _doNotQuit(self):
"""Dumb method to override window's close button."""
return
示例12: __init__
class _Testdialog:
"""Only used to test dialog from CLI"""
def __init__(self, master):
"""Initialize CLI test GUI"""
frame = Frame(master, width=300, height=300)
self.master = master
self.x, self.y, self.w, self.h = -1,-1,-1,-1
self.Button_1 = Button(frame, text="My Popup", relief="raised", width="15")
self.Button_1.pack()
self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)
statframe = Frame(frame)
master.statusMessage = StringVar()
master.statusMessage.set('Welcome')
self.statusbar = Label(statframe, textvariable=master.statusMessage,
bd=1, relief=SUNKEN, anchor=W)
self.statusbar.pack(anchor=SW, fill=X, side=BOTTOM)
statframe.pack(anchor=SW, fill=X, side=BOTTOM)
self.dx = 30
self.dy = 30
frame.pack()
self.dialog = None
# pylint: disable=W0613
def Button_1_Click(self, event): #click method for component ID=1
"""Launch Select_Py_Version for CLI testing."""
self.dialog = SatelliteWindow(self, self.master, "Test Dialog", dx=self.dx, dy=self.dy)
self.dx += 30
self.dy += 30
示例13: __init__
def __init__(self,master):
self.master = master
self.nupud = []
self.laua_suurus = 15
self.laua_suurusR = self.laua_suurus ** 2
self.kaik = 0
self.alustav_mangija = 6
self.main_frame = Frame(master)
self.main_frame.pack(fill="both", expand=True)
self.label = Label(self.main_frame, text='Andre Gomoku', height=2, bg='white smoke', fg='darkblue')
self.label.pack(fill="both", expand=True)
self.ülemine_frame = Frame(self.main_frame)
self.ülemine_frame.pack(fill="both", expand=True)
self.player1 = Label(self.ülemine_frame, text="Player1 score: 0", height=1, bg='white', fg='purple')
self.player1.pack(fill="both", expand=True, side=LEFT)
self.player2 = Label(self.ülemine_frame, text="Player2 score: 0", height=1, bg='white', fg='green')
self.player2.pack(fill="both", expand=True, side=RIGHT)
self.label.pack(fill="both", expand=True)
self.canvas = Canvas(self.main_frame, width=525, height=425)
self.canvas.pack(fill="both", expand=True)
self.alumine_frame = Frame(self.main_frame)
self.alumine_frame.pack(fill="both", expand=True)
self.vs_inimene = Button(self.alumine_frame, text='Vajuta siia, et mängida Sõbra vastu',
command=self.inimene_inimene, height=2, bg='white', fg='purple')
self.vs_inimene.pack(fill="both", expand=True, side=LEFT)
self.vs_arvuti = Button(self.alumine_frame, text='Vajuta siia, et mängida Arvuti vastu',
command=self.inimene_arvuti, height=2, bg='white', fg='green')
self.vs_arvuti.pack(fill="both", expand=True, side=RIGHT)
示例14: view_new_title
def view_new_title(self, Medikom, entry_type):
self.selected_id = False
self.overview(Medikom)
if entry_type == 0:
text = "Titel der neuen Aufgabe:"
elif entry_type == 1:
text = "Titel der neuen Information:"
details_label = Label(
self, text=text, font='Liberation 10',
fg='Black')
details_label.place(
x=self.SPACE_TWO / 2,
y=(self.n + 2) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_TWO, height=self.ROW_HIGHT)
textframe = Text(self, font='Liberation 12', height=1, width=int(self.WIN_WIDTH / 4))
textframe.place(
x=self.SPACE_TWO, y=(self.n + 3) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_ONE - 10, height=self.ROW_HIGHT)
create_button = Button(
self, text='Erstellen',
command=lambda: self.add_entry(Medikom, entry_type, textframe.get(1.0, END).strip()))
create_button.place(
x=(self.WIN_WIDTH / 2) - (self.WIN_WIDTH / 16),
y=(self.n + 4) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH / 8, height=self.ROW_HIGHT)
示例15: InfoFrame
class InfoFrame(Frame):
def __init__(self,master=None, thread=None):
Frame.__init__(self, master)
self.controlThread=thread
self.stringVar=StringVar()
self.grid()
self.createWidgets()
def createWidgets(self):
self.inputText=Label(self)
if self.inputText != None:
self.inputText['textvariable']=self.stringVar
self.inputText["width"] = 50
self.inputText.grid(row=0, column=0, columnspan=6)
else:
pass
self.cancelBtn = Button(self, command=self.clickCancelBtn) # need to implement
if self.cancelBtn !=None:
self.cancelBtn["text"] = "Cancel"
self.cancelBtn.grid(row=0, column=6)
else:
pass
def clickCancelBtn(self):
print("close the InfoDialog")
self.controlThread.setStop()
def updateInfo(self, str):
self.stringVar.set(str)