本文整理汇总了Python中tkinter.ttk.Frame.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.pack方法的具体用法?Python Frame.pack怎么用?Python Frame.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Frame
的用法示例。
在下文中一共展示了Frame.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def __init__(self, parentWindow, title=None, okText=None, cancelText=None, geometry=None):
tk.Toplevel.__init__( self, parentWindow )
self.transient( parentWindow )
self.parentWindow = parentWindow
if title: self.title( title )
self.result = None # Used to return an optional result
if okText is None: okText = _("Ok")
self.okText = okText
if cancelText is None: cancelText = _("Cancel")
self.cancelText = cancelText
self.makeButtonBox()
body = Frame( self )
self.initial_focus = self.makeBody( body ) # Create the widgets in the body
body.pack( padx=5, pady=5, fill=tk.BOTH, expand=tk.YES )
self.grab_set()
if not self.initial_focus:
self.initial_focus = self
self.protocol( 'WM_DELETE_WINDOW', self.cancel ) # Ensure that closing the dialog does a cancel
self.geometry( geometry if geometry else "+{}+{}".format(parentWindow.winfo_rootx()+50, parentWindow.winfo_rooty()+50) )
self.parentWindow.parentApp.setStatus( _("Waiting for user input…") )
self.initial_focus.focus_set()
self.wait_window( self )
示例2: add_buttons
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def add_buttons(self):
frame = Frame(self)
frame.pack(fill="x")
edit = Button(frame, text="Edit", command=self.edit)
edit.pack(side="right", padx=5, pady=5)
delete = Button(frame, text="Del", command=self.delete_menu)
delete.pack(side="right")
示例3: __init__
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def __init__(self, parent, title=None, okText=None, cancelText=None):
tk.Toplevel.__init__( self, parent )
self.transient( parent )
self.parent = parent
if title: self.title( title )
if okText is None: okText = _("Ok")
self.okText = okText
if cancelText is None: cancelText = _("Cancel")
self.cancelText = cancelText
self.result = None # Used to return an optional result
body = Frame( self )
self.initial_focus = self.body( body ) # Create the widgets in the body
body.pack( padx=5, pady=5 )
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus = self
self.protocol( "WM_DELETE_WINDOW", self.cancel ) # Ensure that closing the dialog does a cancel
self.geometry( "+{}+{}".format(parent.winfo_rootx()+50, parent.winfo_rooty()+50) )
self.parent.parentApp.setStatus( _("Waiting for user input...") )
self.initial_focus.focus_set()
self.wait_window( self )
示例4: _replace_dialog
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def _replace_dialog(parent): # htest #
from tkinter import Toplevel, Text, END, SEL
from tkinter.ttk import Frame, Button
top = Toplevel(parent)
top.title("Test ReplaceDialog")
x, y = map(int, parent.geometry().split('+')[1:])
top.geometry("+%d+%d" % (x, y + 175))
# mock undo delegator methods
def undo_block_start():
pass
def undo_block_stop():
pass
frame = Frame(top)
frame.pack()
text = Text(frame, inactiveselectbackground='gray')
text.undo_block_start = undo_block_start
text.undo_block_stop = undo_block_stop
text.pack()
text.insert("insert","This is a sample sTring\nPlus MORE.")
text.focus_set()
def show_replace():
text.tag_add(SEL, "1.0", END)
replace(text)
text.tag_remove(SEL, "1.0", END)
button = Button(frame, text="Replace", command=show_replace)
button.pack()
示例5: __init__
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
container = Frame(self)
self.title("3d Printer")
#This fied is populated on the first view
#and displayed on the second
self.customer_id = StringVar()
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (CreateCustomerView, ExecuteScriptView):
frame = F(container, self)
self.frames[F] = frame
# put all of the pages in the same location;
# the one on the top of the stacking order
# will be the one that is visible.
frame.grid(row=0, column=0, sticky="nsew")
self.model = CreateCustomerModel()
self.show_frame(CreateCustomerView)
示例6: initialize_ui
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def initialize_ui(self):
default_padding = {'padx': 10, 'pady' : 10}
customer_frame = Frame(self)
self.customer_id_label = Label(customer_frame, text = "Customer id:", style="BW.TLabel")
self.customer_id_label.pack(default_padding, side = LEFT)
self.customer_id_value = Label(customer_frame,style="BW.TLabel")
self.customer_id_value["textvariable"] = self.controller.customer_id
self.customer_id_value.pack(default_padding, side = LEFT)
customer_frame.pack(expand = True, fill = "x")
self.take_picture_frame = Frame(self, border = 10)
self.picture_mode = IntVar()
Radiobutton(self.take_picture_frame, text = "Light", variable = self.picture_mode, value = 1).pack(side = LEFT)
Radiobutton(self.take_picture_frame, text = "Dark", variable = self.picture_mode, value = 2).pack(side = LEFT)
self.button_take_picture = Button(self.take_picture_frame, text = "Take picture", command = self.take_picture)
self.button_take_picture.pack(expand = True, fill = "x", side = BOTTOM)
self.take_picture_frame.pack(expand = True)
self.button_update = Button(self, text = "Update", command = self.controller.run_update_script)
self.button_update.pack(expand = True, fill = "x")
示例7: ok_cancel_buttons
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def ok_cancel_buttons(self):
button_frame = Frame(self.frame)
ok_button = Button(button_frame, text="Ok", command=self.save)
cancel_button = Button(button_frame, text="Cancel", command=self.destroy)
button_frame.pack(fill="x")
cancel_button.pack(side="right", padx=5, pady=5)
ok_button.pack(side="right")
示例8: insert_entry_field
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def insert_entry_field(self, txt):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Entry(frame)
entry.pack(fill="x", padx=5, pady=5, expand=True)
self.entries["Entry"][txt] = entry
示例9: __init__
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Example Form")
self.pack(fill=BOTH, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='First Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.firstName = Entry(f)
self.firstName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Last Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.lastName = Entry(f)
self.lastName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Full Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.fullName = Label(f, text='ALEX POOPKIN', width=10)
self.fullName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='', width=10)
l.pack(side=LEFT, padx=5, pady=0)
self.errorMessage = Label(f, text='Invalid character int the name!', foreground='red', width=30)
self.errorMessage.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
b = Button(f, text='Close', command=lambda : self.parent.quit())
b.pack(side=RIGHT, padx=5, pady=10)
b['default'] = ACTIVE
b.focus_set()
self.clearButton = Button(f, text='Clear')
self.clearButton.pack(side=RIGHT, padx=5, pady=10)
self.clearButton['state'] = DISABLED
self.sendButton = Button(f, text='Send')
self.sendButton.pack(side=RIGHT, padx=5, pady=10)
示例10: ok_cancel_buttons
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def ok_cancel_buttons(self, call=None):
if not call:
call = self.save
button_frame = Frame(self.frame)
ok_button = Button(button_frame, text="Ok", command=call)
cancel_button = Button(button_frame, text="Cancel", command=self.destroy)
button_frame.pack(fill="x")
cancel_button.pack(side="right", padx=5, pady=5)
ok_button.pack(side="right")
示例11: insert_text_field
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def insert_text_field(self, txt, default=None):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Text(frame)
entry.pack(fill="both", pady=5, padx=5, expand=True)
if default:
entry.insert("end", default)
self.entries["Text"][txt] = entry
示例12: Node
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
class Node(Toplevel):
""" This class is a catchall for all popup windows."""
def __init__(self, parent, name, pos=(0,0)):
Toplevel.__init__(self)
self.parent = parent
self.name = name
self.pos = pos
self.entries = {"Entry":{}, "Text":{}}
self.resizable(0,0)
self.frame = Frame(self)
self.frame.pack(side="right", fill="y", expand=True)
def save(self):
for i in self.entries["Entry"]:
entry = self.entries["Entry"][i].get()
entr_list = entry.split(",")
self.entries["Entry"][i] = entr_list
for i in self.entries["Text"]:
self.entries["Text"][i] = self.entries["Text"][i].get("1.0", "end-1c")
self.destroy()
self.parent.save_info(self.name, self.entries, self.pos)
def ok_cancel_buttons(self, call=None):
if not call:
call = self.save
button_frame = Frame(self.frame)
ok_button = Button(button_frame, text="Ok", command=call)
cancel_button = Button(button_frame, text="Cancel", command=self.destroy)
button_frame.pack(fill="x")
cancel_button.pack(side="right", padx=5, pady=5)
ok_button.pack(side="right")
def insert_entry_field(self, txt, default=None, focus=False):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Entry(frame)
entry.pack(fill="x", padx=5, pady=5, expand=True)
if default:
entry.insert("end", default)
if focus:
entry.focus_force()
self.entries["Entry"][txt] = entry
def insert_text_field(self, txt, default=None):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Text(frame)
entry.pack(fill="both", pady=5, padx=5, expand=True)
if default:
entry.insert("end", default)
self.entries["Text"][txt] = entry
示例13: initUI
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("GPA Calculator")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
calculateButton = Button(self, text="Calculate", command=lambda: self.onPressCalc)
calculateButton.pack(side=RIGHT, padx=5, pady=5)
示例14: insert_entry_field
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def insert_entry_field(self, txt, default=None, focus=False):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Entry(frame)
entry.pack(fill="x", padx=5, pady=5, expand=True)
if default:
entry.insert("end", default)
if focus:
entry.focus_force()
self.entries["Entry"][txt] = entry
示例15: button_box
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import pack [as 别名]
def button_box(self):
separ = Separator(self, orient="horizontal")
separ.pack(expand=1, fill="x")
box = Frame(self)
b = Button(box, text=self.btn_ok_text, width=10,
command=self.accept, default="active")
b.pack(side="left", padx=5, pady=5)
b = Button(box, text=self.btn_cancel_text, width=10,
command=self.destroy)
b.pack(side="right", padx=5, pady=5)
self.bind("<Return>", self.accept)
self.bind("<Escape>", self.destroy)
box.pack()