本文整理汇总了Python中tkinter.Entry.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.pack方法的具体用法?Python Entry.pack怎么用?Python Entry.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Entry
的用法示例。
在下文中一共展示了Entry.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Demo
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class Demo(Frame):
def __init__(self, parent, *args, **kw):
Frame.__init__(self, parent, *args,**kw)
self.e=Entry(self, text='Message')
self.e.delete(0,'end')
self.e.pack()
self.makebuttons()
self.pack(expand='true',fill='x')
def makebuttons(self):
self.b1=Button(self, text="restart",bg="blue",fg='white',command= self.restart )
self.b1.pack(side='right',fill='both' )
self.b2=Button(self,text='quit',bg='green',fg='white',command=self.quit)
self.b2.pack(side='left',fill='both')
self.lastTime=""
self.start_timer()
def start_timer(self):
pass
def destroy(self):
self.pack_forget()
def restart(self):
self.destroy()
D=Demo(root,bg='purple')
print ("killed")
D.__init__(self,root)
pass
def quit(self):
root.destroy()
示例2: GuiGenerateCount
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class GuiGenerateCount(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.pack()
#step increment len
self._stepLenFrm = Frame(self); self._stepLenFrm.pack()
self._stepLenLbl = Label(self._stepLenFrm, text="Step Len: "); self._stepLenLbl.pack(side=LEFT)
self._stepLenSpin = Spinbox(self._stepLenFrm, from_=0, to=1000); self._stepLenSpin.pack(side=LEFT)
#start value
self._startFrm = Frame(self); self._startFrm.pack()
self._startLbl = Label(self._startFrm, text="Start Value: "); self._startLbl.pack(side=LEFT)
self._startTxt = Entry(self._startFrm); self._startTxt.pack(side=LEFT)
self._startTxt.insert(0, "0")
def getSettings(self):
return { "StepLen": self._stepLenSpin.get(),
"StartValue": self._startTxt.get()
}
def getName(self):
return "Counter"
def getGeneratorFunction(self):
return generateCounter
示例3: ua_win_tk
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def ua_win_tk(url, pipe = None):
from tkinter import Tk, Frame, Label, Entry, StringVar, BOTH, Button, RIGHT
import sys
sys.stdout.flush()
instructions = "Visit the following URL to authorize the application:"
response = {"x": False}
root = Tk()
root.title("oAuth2 Authorization Required")
webbox = Frame(root)
instructions = Label(webbox, text = instructions)
instructions.pack(padx = 5, pady = 5)
urlstr = StringVar(value = url)
urlbox = Entry(webbox, textvariable = urlstr, state = "readonly")
urlbox.pack(padx = 5, pady = 5)
def open_browser():
from subprocess import Popen
p = Popen(["sensible-browser", url])
browserbutton = Button(webbox, text = "Open in web browser", command = open_browser)
browserbutton.pack(padx = 5, pady = 5)
webbox.pack(fill = BOTH, expand = 1)
if pipe:
def poll():
if pipe.poll():
root.destroy()
#Mutability ftw... wat
response["x"] = True
else:
root.after(300, poll)
root.after(300, poll)
cancelbutton = Button(root, text = "Cancel", command = root.destroy)
cancelbutton.pack(side = RIGHT, padx = 5, pady = 5)
root.mainloop()
return response["x"]
示例4: PlusTwo
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class PlusTwo(Frame):
def __init__(self):
'the constructor for the GUI'
Frame.__init__(self)
self.make_widgets()
self.pack()
def make_widgets(self):
'create the widgets for the GUI'
Label(self, text="Please enter a numeric expression:").pack()
self.ent = Entry(self)
self.ent.pack()
Button(self, text="+2", command=self.addtwo).pack(side=LEFT)
Button(self, text="Clear", command=lambda: self.ent.delete(0, END)).pack(side=RIGHT)
# Write this method
def addtwo(self):
'the event handler for the +2 button'
try:
val=eval(self.ent.get())
res=val+2
self.ent.delete(0,END)
self.ent.insert(END,res)
except:
showinfo(title='Error',message='You need to enter numeric values!')
self.ent.delete(0,END)
示例5: show_captcha
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def show_captcha(self,img_file):
dialogRoot = Tk()
dialogRoot.title("Input text.")
img = PhotoImage(file=img_file)
frame = Frame(dialogRoot)
imal = Label(frame, image=img)
imal.pack()
label = Label(frame)
label['text'] = "Your Input:"
label.pack(side=LEFT)
inputEntry = Entry(frame)
inputEntry["width"] = 50
inputEntry.pack(side=LEFT)
def getInputText():
'''callback of button'''
# global inputEntry, dialogRoot
if inputEntry.get().strip() == "":
print("Please enter a message.")
else:
self.captcha_ans = inputEntry.get().strip()
dialogRoot.destroy()
button = Button(frame, text="Submit", command=getInputText)
button.pack(side=LEFT)
frame.pack()
dialogRoot.mainloop()
示例6: FrameKSPObject
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class FrameKSPObject(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
frame = Frame(self)
frame.pack()
self.string_var0 = StringVar()
self.string_var1 = StringVar()
self.int_var = IntVar()
self.entry0 = Entry(frame, textvariable=self.string_var0)
self.entry0.pack(side='left')
Entry(frame, textvariable=self.string_var1).pack(side='left')
frame = Frame(self)
frame.pack()
Button(frame, width=8, text='Accept', command=self.accept).pack(side='left')
Button(frame, width=8, text='Cancel', command=self.cancel).pack(side='left')
Button(frame, width=8, text='Delete', command=self.delete).pack(side='left')
def populate(self, kspobject):
self._kspobject = kspobject
self.string_var0.set(kspobject.name)
self.string_var1.set(kspobject.value)
self.int_var.set(kspobject.id_)
def accept(self):
name = self.string_var0.get()
value = self.string_var1.get()
id_ = self.int_var.get()
self.master.master.update_kspobject(name, value, id_)
self.master.destroy()
def cancel(self):
self.master.destroy()
def delete(self):
id_ = self.int_var.get()
self.master.master.delete_kspobject(id_)
self.master.destroy()
示例7: NewUser
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class NewUser(object):
def __init__(self,master):
top=self.top=Toplevel(master)
self.l=Label(top,text="Enter PIN from Twitter")
self.l.pack()
self.e=Entry(top)
self.e.pack()
self.b=Button(top,text='Ok',command=self.cleanup)
self.b.pack()
def cleanup(self):
self.value=self.e.get()
self.top.destroy()
示例8: editSettings
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def editSettings(cls):
def commitSettings(messageInDialogIn):
try:
SettingsVars.DEFAULT_BOARD = defaultBoardBox.get()
SettingsVars.REFRESH_INTERVAL = int(refreshIntervalBox.get())
messageInDialogIn.destroy()
except ValueError:
messagebox.showwarning(message="Invalid Settings")
messageInDialogIn.focus_force()
settingsDialog = Tk()
settingsDialog.title('Settings')
try:
if os.name == "nt":
settingsDialog.wm_iconbitmap(bitmap='./gui/images/icon.ico')
except _tkinter.TclError:
pass
settingsDialog.columnconfigure(0, weight=1)
settingsDialog.rowconfigure(0, weight=1)
settingsDialog.minsize(width=100, height=50)
frame = Frame(settingsDialog)
refreshIntervalLabel = Label(frame)
refreshIntervalLabel['text'] = 'Refresh Interval'
refreshIntervalLabel.pack()
refreshIntervalBox = Entry(frame)
refreshIntervalBox.insert(0, cls.REFRESH_INTERVAL)
refreshIntervalBox.pack(fill='both')
defaultBoardLabel = Label(frame)
defaultBoardLabel['text'] = 'Default Board'
defaultBoardLabel.pack()
defaultBoardBox = Entry(frame)
defaultBoardBox.insert(0, cls.DEFAULT_BOARD)
defaultBoardBox.pack(fill='both')
submitButton = Button(frame)
submitButton['text'] = 'Ok'
submitButton['command'] = lambda: commitSettings(settingsDialog)
submitButton.pack(side="left", expand="yes", fill="both", padx=5, pady=3)
cancelButton = Button(frame)
cancelButton['text'] = 'Cancel'
cancelButton['command'] = settingsDialog.destroy
cancelButton.pack(fill='both', expand="yes", padx=5, pady=3)
frame.pack(fill='both', expand="yes", padx=0, pady=0)
return settingsDialog
示例9: makeform
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def makeform(root, fields):
entries = []
for field in fields:
row = Frame(root)
lab = Label(row, width=15, text=field[0], anchor='w')
ent = Entry(row)
row.pack(side=TOP, fill=X, padx=5, pady=5)
lab.pack(side=LEFT)
ent.pack(side=RIGHT, expand=YES, fill=X)
ent.config(show=field[1])
ent.insert(0, field[2])
entries.append((field[0], ent))
return entries
示例10: __init__
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.entry = Entry(frame)
self.entry.pack(side=LEFT)
self.entry.bind('<Return>', self.on_click)
def on_click(self, event):
print('ENTER')
self.entry.delete(0, 'end')
示例11: add_widgets
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def add_widgets(self):
# File
frame = Frame(self.root)
frame.pack(side=TOP, fill=X, expand=True, ipady=5)
file_label = Label(frame, text="PDF File", width=10)
file_label.pack(side=LEFT, padx=5, pady=5)
file_entry = Entry(frame, state=DISABLED, textvariable=self.file_name)
file_entry.pack(padx=5, side=LEFT, fill=X, expand=True)
file_button = Button(frame, text="Browse...", command=self.choose_pdf)
file_button.pack(padx=5, side=RIGHT)
# Case
frame = Frame(self.root)
frame.pack(side=TOP, fill=X, expand=True)
case_label = Label(frame, text="Case", width=10)
case_label.pack(side=LEFT, padx=5, pady=5)
case_entry = Entry(frame, textvariable=self.default_case)
case_entry.pack(fill=X, padx=5, expand=True)
# Team
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
team_label = Label(frame, text="Team", width=10)
team_label.pack(side=LEFT, padx=5, pady=5)
team_entry = Entry(frame, textvariable=self.default_team)
team_entry.pack(fill=X, padx=5, expand=True)
# Series
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
series_label = Label(frame, text="Series", width=10)
series_label.pack(side=LEFT, padx=5, pady=5)
series_entry = Entry(frame, textvariable=self.default_series)
series_entry.pack(fill=X, padx=5, expand=True)
# Last index
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
last_index_label = Label(frame, text="Last index", width=10)
last_index_label.pack(side=LEFT, padx=5, pady=5)
last_index_entry = Entry(frame, textvariable=self.default_last_index)
last_index_entry.pack(fill=X, padx=5, expand=True)
bottom_frame = Frame(self.root)
bottom_frame.pack(side=BOTTOM, fill=X, ipady=5, padx=5)
close_button = Button(bottom_frame, text="Quit", command=self.root.quit)
close_button.pack(side=RIGHT)
self.stamp_button = Button(bottom_frame, text="Stamp it!", state=DISABLED, command=self.stamp_it)
self.stamp_button.pack(side=RIGHT)
示例12: AeriesApp
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
class AeriesApp(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.pack()
self.email_label = Label(self, text="Email:", padx="70", pady="5")
self.pass_label = Label(self, text="Password:", padx="70", pady="5")
self.email_input = Entry(self)
self.pass_input = Entry(self, show="\u2022")
self.submit = Button(self, text="Submit",
command=self.validate_form, pady="10")
self.pack_widgets()
def validate_form(self):
user_email = self.email_input.get()
user_pass = self.pass_input.get()
if len(user_email) == 0 or len(user_pass) == 0:
raise AeriesAppException("No email or password entered")
try:
a = login.AeriesLogin(user_email, user_pass)
self.display_grades()
except login.AeriesLoginException:
raise AeriesAppException("Failed to login")
def get_grades(self):
conn = connect("grades.db")
c = conn.cursor()
parser.run(conn, c)
return [line for line in c.execute("SELECT * FROM grades")]
def display_grades(self):
for course in self.get_grades():
if len(course[1]) != 0:
string = "%s\t%s" % (course[0], course[1])
else:
string = "%s\t%s" % (course[0], "NA")
Label(text=string).pack()
def pack_widgets(self):
self.email_label.pack()
self.email_input.pack()
self.pass_label.pack()
self.pass_input.pack()
self.submit.pack()
示例13: __init__
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def __init__(self, parent, label_text, is_password, initial_value):
Frame.__init__(self, parent)
self.value = StringVar()
self.value.set(initial_value)
label = Label(self, text=label_text)
label.pack(side=LEFT)
if is_password:
entry = Entry(self, show="*", textvariable=self.value)
else:
entry = Entry(self, textvariable=self.value)
entry.pack(side=RIGHT)
# parent.window_create("end", window=self)
self.pack()
示例14: __init__
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def __init__(self):
super().__init__()
self.title('Hangman')
self.geometry('640x480+200+200')
self.resizable(width=False, height=False)
menu_bar = Menu(self, tearoff=0)
self.config(menu=menu_bar)
game_menu = Menu(menu_bar, tearoff=0)
game_menu.add_command(label='New game', command=self.__on_new_game)
game_menu.add_command(label='Quit', command=self.__on_quit)
menu_bar.add_cascade(label='Game', menu=game_menu)
self.__hang_canvas = Canvas(self, background='#ffffff')
self.__hang_canvas.pack(fill=BOTH, expand=True)
self.__dict_filename = os.path.join(os.path.dirname(__file__), 'dictionary.txt')
self.__dictionary = []
self.__secret_word_masked = StringVar()
self.__game_stages = (
# (is_circle, x1, y1, x2, y2),
(False, 50, 300, 200, 300), # podstawa
(False, 60, 300, 60, 10), # maszt
(False, 60, 10, 160, 10),
(False, 60, 30, 100, 10),
(False, 160, 10, 160, 30),
(True, 140, 30, 180, 70),
(False, 160, 70, 160, 200), # tułów
(False, 140, 120, 160, 70), # lewa reka
(False, 180, 120, 160, 70), # prawa ręka
(False, 160, 200, 140, 250),
(False, 160, 200, 180, 250)
)
self.__errors_count = 0
secret_word_label = Label(self, font=('purisa', 36), textvariable=self.__secret_word_masked)
secret_word_label.pack(fill=X)
# user input panel
Label(self, text='Please input a char:').pack(fill=X)
self.__user_input_char = StringVar()
user_input_entry = Entry(self, textvariable=self.__user_input_char)
user_input_entry.bind('<Return>', self.__on_user_input)
user_input_entry.pack()
self.__load_dictionary()
self.__new_game()
示例15: main
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import pack [as 别名]
def main():
window = Tk()
window.title('A. Dobrunov')
window.resizable(width=False, height=False)
color1 = 'lightgreen'
frame = Frame(window, bg=color1)
frame.pack()
Label(frame, text="Laborarbeit № 1 , Variante № 1\n", justify=CENTER, font=("Helvetica", 12), bd=10, bg=color1).pack()
Label(frame, text="\n Punkte:", justify=CENTER, font=("Helvetica", 12), bd=0, bg=color1).pack()
e = Entry(frame, bd = 2)
e.pack()
Label(frame, text='\n', bg=color1).pack()
button = Button(frame, text="Ausführen", font=("Helvetica", 12), bg='white', command=lambda: Paint(int(e.get())))
button.pack()
window.mainloop()