本文整理汇总了Python中ttk.Label.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Label.pack方法的具体用法?Python Label.pack怎么用?Python Label.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Label
的用法示例。
在下文中一共展示了Label.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.selected = "";
self.controller = controller
label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label.pack(side="top", fill="x", pady=10)
self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose)
button2 = Button(self, text="Refresh", command=self.callback_refresh)
button3 = Button(self, text="Back", command=self.callback_start)
scrollbar = Scrollbar(self)
self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set )
self.mylist.bind("<Double-Button-1>", self.twoClick)
self.button1.pack()
button2.pack()
button3.pack()
# create list with a scroolbar
scrollbar.pack( side = "right", fill="y" )
self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 )
scrollbar.config( command = self.mylist.yview )
# create a progress bar
label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center')
label2.pack(side="top", fill="x")
self.bar_lenght = 200
self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate')
self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10)
self.pb.config(value=0)
示例2: Example
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("ListBox")
self.pack(fill=BOTH, expand=1)
eagles = ["Sam Bradford", "Jordan Matthews", "LeBron James", "Donnie Jones"]
lb = Listbox(self)
for i in eagles:
lb.insert(END, i)
lb.bind("<<ListboxSelect>>", self.onSelect)
lb.pack(pady=15)
self.var = StringVar()
self.label = Label(self, text=0, textvariable=self.var)
self.label.pack()
def onSelect(self, val):
sender = val.widget
idx = sender.curselection()
value = sender.get(idx)
self.var.set(value)
示例3: Example
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Scale")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
scale = Scale(self, from_=0, to=100,
command=self.onScale)
scale.pack(side=LEFT, padx=15)
self.var = IntVar()
self.label = Label(self, text=0, textvariable=self.var)
self.label.pack(side=LEFT)
def onScale(self, val):
v = int(float(val))
self.var.set(v)
示例4: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def initUI(self):
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("alt")
# Styling
self.style.configure('.', font=('Helvetica', 12), background="#300A24")
self.style.configure(
"PW.TLabel", foreground="#fff", background="#300A24", padding=20, justify=CENTER, wraplength="350")
self.style.configure(
"Medium.TButton", foreground="#300A24", background="#fff", borderwidth=0, padding=8, font=('Helvetica', 9))
# Styling Ends
quoteLabel = Label(self, text=self.quote, style="PW.TLabel")
quoteLabel.pack()
authorLabel = Label(self, text=self.author, style="PW.TLabel")
authorLabel.pack()
self.pack(fill=BOTH, expand=True)
closeButton = Button(self, text="Close This",
style="Medium.TButton", command=self.parent.quit)
closeButton.pack(side=RIGHT)
projectButton = Button(self, text=self.project[0]["name"],
style="Medium.TButton", command=lambda: self.btnFn(0))
projectButton.pack(side=RIGHT)
projectButton = Button(self, text=self.project[1]["name"],
style="Medium.TButton", command=lambda: self.btnFn(1))
projectButton.pack(side=RIGHT)
projectButton = Button(self, text=self.project[2]["name"],
style="Medium.TButton", command=lambda: self.btnFn(2))
projectButton.pack(side=RIGHT)
示例5: Login
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class Login(Frame):
"""******** Funcion: __init__ **************
Descripcion: Constructor de Login
Parametros:
self Login
parent Tk
Retorno: void
*****************************************************"""
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
"""******** Funcion: initUI **************
Descripcion: Inicia la interfaz grafica de un Login,
para ello hace uso de Frames y Widgets.
Parametros:
self Login
Retorno: void
*****************************************************"""
def initUI(self):
self.parent.title("Pythagram: Login")
self.style = Style()
self.style.theme_use("default")
self.frame = Frame(self, relief=RAISED)
self.frame.pack(fill=BOTH, expand=1)
self.instructions = Label(self.frame,text="A new Web Browser window will open, you must log-in and accept the permissions to use this app.\nThen you have to copy the code that appears and paste it on the next text box.")
self.instructions.pack(fill=BOTH, padx=5,pady=5)
self.codeLabel = Label(self.frame,text="Code:")
self.codeLabel.pack(fill=BOTH, padx=5,pady=5)
self.codeEntry = Entry(self.frame)
self.codeEntry.pack(fill=BOTH, padx=5,pady=5)
self.pack(fill=BOTH, expand=1)
self.closeButton = Button(self, text="Cancel", command=self.quit)
self.closeButton.pack(side=RIGHT, padx=5, pady=5)
self.okButton = Button(self, text="OK", command=self.login)
self.okButton.pack(side=RIGHT)
"""******** Funcion: login **************
Descripcion: Luego que el usuario ingresa su codigo de acceso, hace
la solicitud al servidor para cargar su cuenta en una
ventana de tipo Profile
Parametros:
self
Retorno: Retorna...
*****************************************************"""
def login(self):
code = self.codeEntry.get()
api = InstagramAPI(code)
raw = api.call_resource('users', 'info', user_id='self')
data = raw['data']
self.newWindow = Toplevel(self.parent)
global GlobalID
GlobalID = data['id']
p = Profile(self.newWindow,api,data['id'])
示例6: gui
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class gui(Frame):
def __init__(self,master=Tk()):
Frame.__init__(self,master)
self.grid()
self.image = Image.open("test.jpg")
self.photo = PhotoImage(self.image)
self.label = Label(master,image=self.photo)
self.label.image = photo
self.label.pack()
示例7: pack_text
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def pack_text(self, text, frame=None):
"""adds some label text in the desired location"""
if frame is None:
label = Label(self.window, text=text)
else:
label = Label(frame, text=text)
label.pack()
示例8: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def initUI(self):
self.parent.title("Review")
self.pack(fill=BOTH, expand=True)
frame1 = Frame(self)
frame1.pack(fill=X)
lbl1 = Label(frame1, text="Title", width=6)
lbl1.pack(side=LEFT, padx=5, pady=5)
entry1 = Entry(frame1)
entry1.pack(fill=X, padx=5, expand=True)
示例9: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def initUI(self):
self.parent.title("Simple FTP-Client")
self.pack(fill=BOTH, expand=True)
# self.parent.title("Buttons")
#frame2 = Frame(self)
#frame2.pack(anchor=W,side=LEFT)
#lbl2 = Label(frame2, text="Command Line", width=6)
#lbl2.pack(fill=X,anchor=W,expand=True,padx=5, pady=5)
#txt2 = Text(frame2)
#txt2.pack(fill=X,side=BOTTOM,pady=5, padx=5)
frame3 = Frame(self, width=400, height=500)
frame3.pack(side=BOTTOM,anchor=NW)
lbl3 = Label(frame3, text="Command Line", width=6)
lbl3.pack(fill=X,anchor=NE,expand=True,padx=5, pady=5)
txt = Text(frame3)
txt.pack(fill=BOTH,pady=5, padx=5)
wid = frame3.winfo_id()
os.system('xterm -into %d -geometry 400x400 -sb &' % wid)
f1 = Frame(self)
f1.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
lb=Label(f1, text="Host:").grid(row=0, column=0)
e1 = Entry(f1)
e1.grid(row=0, column=1, padx=1)
f2 = Frame(self)
f2.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
lb2=Label(f2, text="Username:").grid(row=0, column=2)
e2 = Entry(f2)
e2.grid(sticky=N,row=0, column=3, padx=5)
f3 = Frame(self)
f3.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
lb=Label(f3, text="Password:").grid(row=0, column=0)
e3 = Entry(f3)
e3.grid(row=0, column=1, padx=5)
f4 = Frame(self)
f4.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
lb4=Label(f4, text="Port:").grid(row=0, column=2)
e4 = Entry(f4)
e4.grid(row=0, column=3, padx=5)
connectButton = Button(self, text="Connect", command=callback)
connectButton.pack(expand=True,fill=X,side=LEFT, anchor=NW, padx=10, pady=10)
示例10: loadScriptPage
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def loadScriptPage(self):
# Button States
self.parent.prevButton.config(state='disabled')
if self.parent.scriptname != '':
self.parent.nextButton.config(state='normal')
explain = Label(self, text=txt.selectscript, justify=CENTER, font=root.fontH1)
explain.pack(pady=50)
self.loadedscript = Label(self, text=self.parent.scriptname, justify=CENTER, font=root.fontH1)
self.loadedscript.pack()
loadscriptBtn = Button(self, text="Load Script", command=self.getScript)
loadscriptBtn.pack(pady=10)
示例11: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def initUI(self):
self.parent.title("Pythagram: Search")
self.style = Style()
self.style.theme_use("default")
self.frame = Frame(self,relief=RAISED)
self.frame.pack(fill=BOTH, expand=1)
searchLabel = Label(self.frame, text="Search")
self.searchEntry = Entry(self.frame)
searchLabel.pack(fill=BOTH, padx=5,pady=5)
self.searchEntry.pack(fill=BOTH, padx=5,pady=5)
self.pack(fill=BOTH, expand=1)
okButton = Button(self, text="OK", command=self.search)
okButton.pack(side=RIGHT, padx=5, pady=5)
示例12: UIinit
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def UIinit(self):
self.parent.title('Warning')
self.pack(fill=BOTH, expand=1)
frame1 = Frame(self)
frame1.pack(fill=X)
lbl1 = Label(frame1, text="Are you sure you want to exit the \nexperiment?")
lbl1.pack(side=LEFT, padx=5, pady=5)
frame2 = Frame(self)
frame2.pack(fill=X)
button1 = Button(frame2, text="Yes", command=self.yes)
button1.pack(side=LEFT, padx=5, pady=5)
button2 = Button(frame2, text="No", command=self.stay)
button2.pack(padx=5,pady=5)
示例13: main1
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
def main1():
main_window = Tk()
main_window.geometry("500x500")
main_window.iconbitmap(os.path.abspath(
os.curdir + "\Assets\Alien_robot.ico")) #r"C:\Users\ofer\Desktop\github files\project\Alien_robot.ico")
main_window.wm_title("Personal Helper!")
l = Label(text="Personal helper!")
CheckVal1 = IntVar()
w = Checkbutton(main_window, text="work", variable=CheckVal1, \
onvalue=1, offvalue=0, height=5, \
width=20)
b = Button(main_window, text="start scanning for programs", command=scan_computer_programs)
#c = Button(main_window, text="block all gaming apps", command=running_programs(main_window,True))
l.pack()
b.pack()
c.pack()
w.pack()
print CheckVal1
main_window.mainloop()
示例14: ticketViews
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class ticketViews():
def __init__(self, parent, id):
self.client = client = httplib2.Http(disable_ssl_certificate_validation=True)
self.client.add_credentials(username, password)
## Pull View Name
self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json")
self.viewData = json.loads(self.viewContent)
print repr(self.viewData)
self.countResp, self.countContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + "/count.json")
self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json")
self.countData = json.loads(self.countContent)
print repr(self.countContent)
self.parent = parent
print(self.parent.winfo_width())
self.label = Label(text=self.viewData["view"]["title"] + " " + str(self.countData["view_count"]["value"]))
self.label.pack(fill=BOTH)
示例15: Example
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Review")
self.pack(fill=BOTH, expand=True)
frame1 = Frame(self)
frame1.pack(fill=X)
lbl1 = Label(frame1, text="Your Speed Is:", width=18, font=("Helvetica", 16))
lbl1.pack(padx=5, pady=5)
frame2 = Frame(self)
frame2.pack(fill=X)
mph = Label(frame2, text="MPH", width=6, font=("Helvetica", 20))
mph.pack(side=RIGHT, padx=5, pady=5)
self.speed_text = StringVar()
speed_label = Label(frame2, textvariable = self.speed_text, width = 18, font=("Helvetica", 60))
speed_label.pack(fill=X, padx=5, expand=True)
frame3 = Frame(self)
frame3.pack(fill=BOTH, expand=True)
self.v = StringVar()
self.v.set("Late For Class?")
self.speed = Label(frame3, textvariable=self.v, width=16, font=("Helvetica", 40))
self.speed.pack(padx=5, pady=5)
def updateMetrics(self,speed,message):
formatted_speed = "{0:.2f}".format(speed)
self.speed_text.set(formatted_speed)
print str("{0:.2f}".format(speed))