本文整理汇总了Python中Tkinter.Frame.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.pack方法的具体用法?Python Frame.pack怎么用?Python Frame.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_status_bar
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def build_status_bar(self):
frame_status = Frame(self.parent, height=18)
frame_status.pack(side=BOTTOM, expand=False, fill=X)
self.label_status_bar = Label(frame_status, anchor="w", text=self.get_status_board())
self.label_status_bar.pack(expand=True, fill=X, side=TOP)
示例2: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self):
#Creating main window. And initializing components
Tk.__init__(self)
f = Frame(self, width=400, height=200)
f.pack(expand=True)
#Blank labels are added to make window alignment better
Label(f,text="").grid(row=0)
#Blank labels are added to make window alignment better
Label(f,text=" ").grid(row=1,column=0)
#Add label fileName
Label(f,text="File Name").grid(row=1,column=1)
#Adding text box
self.textbox1=Entry(f,width=20)
self.textbox1.grid(row=1,column=2)
#Adding file Browse button. Set its even handler as openFileBrowser()
Button(f,text="Choose File",command=self.openFileBrowser).grid(row=1,column=3)
#Blank labels are added to make window alignment better
Label(f,text=" ").grid(row=1,column=4)
#Blank labels are added to make window alignment better
Label(f,text="").grid(row=2)
#Adding Summarize button. Set its even handler as summarize()
Button(f,text="Summarize",command=self.summarize).grid(row=3,column=2)
#Adding frame to window
f.pack_propagate(0)
#Set window title
self.title("Auto Text Summarizer")
self.mainloop()
示例3: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self, parent, scrollbar=True, **kw):
parent = mx.get_master(parent)
self.parent = parent
frame = Frame(parent)
frame.pack(fill='both', expand=True)
# text widget
if "wrap" not in kw:
kw["wrap"] = "word"
tk.Text.__init__(self, frame, **kw)
#self.pack(side='left', fill='both', expand=True)
mx.AllMixins.__init__(self, parent)
# scrollbar
if scrollbar:
scrb = Scrollbar(frame, orient='vertical', command=self.yview)
self.config(yscrollcommand=scrb.set)
scrb.pack(side='right', fill='y')
# pop-up menu
self.popup = Menu(self, tearoff=0)
self.popup.add_command(label='Cut', command=self._cut)
self.popup.add_command(label='Copy', command=self._copy)
self.popup.add_command(label='Paste', command=self._paste)
self.popup.add_separator()
self.popup.add_command(label='Select All', command=self._select_all)
self.popup.add_command(label='Clear All', command=self._clear_all)
self.bind('<Button-3>', self._show_popup)
# only allow mouse scroll when mouse inside text
self.bind("<Leave>", lambda event: self.winfo_toplevel().focus_set(), "+")
self.bind("<Enter>", lambda event: self.focus_set(), "+")
示例4: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
class App:
def __init__(self,parent):
# Create frame, buttons, etc
self.f = Frame(parent)
self.f.pack(padx=15,pady=15)
self.entry = Entry(self.f,text="Enter the search term")
self.entry.pack(side= TOP,padx=10,pady=12)
self.entry.bind("<Key>", self.key)
self.entry.focus_set()
self.exit = Button(self.f, text="Exit", command=self.f.quit)
self.exit.pack(side=BOTTOM,padx=10,pady=10)
self.button = Button(self.f, text="Search",command=self.search)
self.button.pack(side=BOTTOM,padx=10,pady=10)
def key(self, event):
# If ENTER was pressed, search
if event.char == '\r':
self.search()
def search(self):
# If there's something to search, search!
if self.entry.get() != '':
self.button.config(text='Searching...', state=DISABLED)
th = SearchThread(self, self.entry.get())
th.start()
else:
tkMessageBox.showinfo('Hey', 'You should type something in the search. That\'s the point, really...')
示例5: show_source_tree
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def show_source_tree(head):
root = Tk()
frame = Frame(root)
frame.pack(fill = 'both')
tree = ttk.Treeview(frame)
#insert root subroutine
# @type head Node
parent_id = tree.insert('', 'end', '', text = head.name)
for child in head.children:
child.insert_to_tree(tree, parent_id)
#add scrollbar
v_scrollbar = Scrollbar(frame, orient = VERTICAL, command = tree.yview)
h_scrollbar = Scrollbar(frame, orient = HORIZONTAL, command = tree.xview)
tree.configure(yscrollcommand = v_scrollbar.set, xscrollcommand = h_scrollbar.set)
v_scrollbar.pack(side = 'right', fill = 'y')
h_scrollbar.pack(side = 'bottom', fill = 'x')
tree.pack(fill = 'both')
root.geometry("600x600")
root.mainloop()
示例6: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
class PlotClass:
def __init__(self,master=[]):
self.master=master
#Erstellen des Fensters mit Rahmen und Canvas
self.figure = Figure(figsize=(7,7), dpi=100)
self.frame_c=Frame(relief = GROOVE,bd = 2)
self.frame_c.pack(fill=BOTH, expand=1,)
self.canvas = FigureCanvasTkAgg(self.figure, master=self.frame_c)
self.canvas.show()
self.canvas.get_tk_widget().pack(fill=BOTH, expand=1)
#Erstellen der Toolbar unten
self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame_c)
self.toolbar.update()
self.canvas._tkcanvas.pack( fill=BOTH, expand=1)
def make_erg_plot(self,kegelst):
self.plot1 = self.figure.add_subplot(111)
self.plot1.set_title("Kegelstumpf Abwicklung")
self.plot1.hold(True)
for geo in kegelst.geo:
geo.plot2plot(self.plot1)
示例7: construct
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def construct(self):
status = Frame(self)
self._update_bar = StatusBar(status)
self._drawer = MazeCanvas.MazePlannerCanvas(self, self._update_bar, manager=self.manager)
self._drawer.pack(expand=True,fill=BOTH)
self._status_bar = StatusBar(status)
Debug.d_level.set_message_pad(self._status_bar)
self._status_bar.pack(side=BOTTOM, fill=X)
self._update_bar.pack(side=BOTTOM, fill=X)
x_scroll = Scrollbar(self._parent, orient=HORIZONTAL)
x_scroll.config(command=self._drawer._canvas.xview)
x_scroll.pack(side=BOTTOM,fill=X)
y_scroll = Scrollbar(self._parent, orient=VERTICAL)
y_scroll.config(command=self._drawer._canvas.yview)
y_scroll.pack(side=RIGHT,fill=Y)
self._drawer._canvas.config(xscrollcommand=x_scroll.set, yscrollcommand=y_scroll.set,
scrollregion=(-MAX_CANVAS_X, -MAX_CANVAS_Y,
MAX_CANVAS_X, MAX_CANVAS_Y))
self._drawer._canvas.bind()
status.pack(side=BOTTOM, fill=X)
示例8: go_action
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def go_action(self, actions):
"""
execute the action script
:param actions:
:return:
"""
# if EMPTY command then do nothing
# hide the menu and show a delay screen
self.hide_top()
delay = Frame(self, bg="#2d89ef")
delay.pack(fill=TkC.BOTH, expand=1)
label = Label(delay, text="Arbetar...", fg="white", bg="#2d89ef", font="Sans 30")
label.pack(fill=TkC.BOTH, expand=1)
self.parent.update()
if "MATA_UT" in actions:
self._hwController.do_dispense_on_floor(6)
if "ON_DEMAND" in actions:
self._hwController.do_dispense_on_floor(12)
# excute shell script
subprocess.call([self.path + '/pimenu.sh'] + actions)
# remove delay screen and show menu again
delay.destroy()
self.destroy_all()
self.show_top()
示例9: initUI
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def initUI(self):
#top frame using all the remaining space
innerTopFrame = Frame(self, background="black")
innerTopFrame.pack(fill=BOTH, expand=1)
#CLOSE Label
innerBottomLeftFrame = Frame(self, background="black")
innerBottomLeftFrame.place(x=0, width=self.wRoot/2,
y=self.hRoot-200, height=200)
closeLabel = Label(innerBottomLeftFrame, bg="black", fg="black",
text="CLOSE", font=("Comic Sans MS", 48, "bold"))
innerBottomLeftFrame.bind("<Enter>", lambda f: closeLabel.config(fg="white"))
innerBottomLeftFrame.bind("<Leave>", lambda f: closeLabel.config(fg="black"))
innerBottomLeftFrame.bind("<Button-1>", lambda f: self.root.quit())
closeLabel.bind("<Button-1>", lambda f: self.root.quit())
closeLabel.pack(fill=BOTH)
#SHUT DOWN Label
innerBottomRightFrame = Frame(self, background="black")
innerBottomRightFrame.place(x=self.wRoot/2, width=self.wRoot/2,
y=self.hRoot-200, height=200)
shutdownLabel = Label(innerBottomRightFrame, bg="black", fg="black",
text="SHUT DOWN", font=("Comic Sans MS", 48, "bold"))
innerBottomRightFrame.bind("<Enter>", lambda f: shutdownLabel.config(fg="white"))
innerBottomRightFrame.bind("<Leave>", lambda f: shutdownLabel.config(fg="black"))
innerBottomRightFrame.bind("<Button-1>", self.shutdown)
shutdownLabel.bind("<Button-1>", self.shutdown)
shutdownLabel.pack(fill=BOTH)
#design the FullScreenApp
self.pack(fill=BOTH, expand=1)
示例10: build_dlg
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def build_dlg(self):
top = self.top
button_frame = self.create_std_buttons(top)
button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
do_apply = self.do_apply
frame = Frame(top)
frame.pack(side = TOP, fill = X, expand = 1, ipady = 2)
label = Label(frame, text = _("Origin:"), anchor = E)
label.grid(row = 0, column = 0, sticky = 'E')
f = Frame(frame)
self.var_xorig = create_length_entry(top, f, do_apply)
f.grid(row = 0, column = 1)
label = Label(frame, text = ',', width = 1)
label.grid(row = 0, column = 2)
f = Frame(frame)
self.var_yorig = create_length_entry(top, f, do_apply)
f.grid(row = 0, column = 3)
label = Label(frame, text = _("Widths:"), anchor = E)
label.grid(row = 1, column = 0, sticky = 'E')
f = Frame(frame)
self.var_xwidth = create_length_entry(top, f, do_apply)
f.grid(row = 1, column = 1)
label = Label(frame, text = 'x', width = 1)
label.grid(row = 1, column = 2)
f = Frame(frame)
self.var_ywidth = create_length_entry(top, f, do_apply)
f.grid(row = 1, column = 3)
示例11: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack(fill=BOTH)
self.message = Label(self, text="Recapitulatif du sismogramme")
self.message.pack()
X=read(textPath.get())
fRecap = Frame(self)
self.recap = Text(fRecap, height =12, width = 70)
self.recap.insert(INSERT, "network: {}\n".format(X[0].stats.network))
self.recap.insert(INSERT, "station: {}\n".format(X[0].stats.station))
self.recap.insert(INSERT, "location: {}\n".format(X[0].stats.location))
self.recap.insert(INSERT, "channel: {}\n".format(X[0].stats.channel))
self.recap.insert(INSERT, "starttime: {}\n".format(X[0].stats.starttime))
self.recap.insert(INSERT, "endtime: {}\n".format(X[0].stats.endtime))
self.recap.insert(INSERT, "sampling rate: {}\n".format(X[0].stats.sampling_rate))
self.recap.insert(INSERT, "delta: {}\n".format(X[0].stats.delta))
self.recap.insert(INSERT, "number points: {}\n".format(X[0].stats.npts))
self.recap.insert(INSERT, "calibration: {}\n".format(X[0].stats.calib))
self.recap.insert(INSERT, "format: {}\n".format(X[0].stats._format))
self.recap.pack()
fRecap.pack()
self.bouton_quitter = Button(self, text="continue", command=self.quit)
self.bouton_quitter.pack(side="bottom")
示例12: main
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def main():
# helper method used when quitting program
def kill_all_threads():
if input_frame.backend_call is not None:
input_frame.backend_call.stop()
input_frame.backend_call.join()
root.destroy()
root = Tk()
root.wm_protocol ("WM_DELETE_WINDOW", kill_all_threads)
root.wm_title("Seating Chart Creator")
centered_window = Frame(root)
centered_window.pack()
header_frame = HeaderFrame(centered_window)
header_frame.grid(row=0, column=0, columnspan=3, sticky=(W))
instructions_frame = InstructionsFrame(centered_window)
instructions_frame.grid(row=1, column=0, columnspan=3, padx=(0,20))
progress_frame = ProgressFrame(centered_window)
progress_frame.grid(row=2, column=1, padx=10, pady=20, sticky=(N))
results_frame = ResultsFrame(centered_window, progress_frame.plot_frame)
results_frame.grid(row=2, column=2, padx=10, sticky=(N))
input_frame = InputFrame(centered_window, progress_frame, results_frame)
input_frame.grid(row=2, column=0, padx=(30,20), sticky=(N))
progress_frame.input_frame = input_frame
results_frame.input_frame = input_frame
root.mainloop()
示例13: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self, master, **kwargs):
Frame.__init__(self, master)
textarea_frame = Frame(self, bd=1, relief=SOLID,**kwargs)
textarea_frame.pack(fill=X)
textarea_frame.pack_propagate(False)
self.textarea = Text(textarea_frame, height=1, pady=self.TAG_ENTRY_PADY, padx=self.TAG_ENTRY_PADX, highlightthickness =0, spacing1=0, spacing2=0, spacing3=0, borderwidth=0, wrap="none")
self.textarea.pack(expand=True, fill=BOTH, padx=2)
scrollbar = Scrollbar(self, orient=HORIZONTAL, command=self.textarea.xview)
scrollbar.pack(fill=X)
self.textarea.configure(xscrollcommand=scrollbar.set)
self.textarea.bind("<KeyPress>",self._on_keypress)
tag = Tag(self.textarea, "")
self.textarea.window_create("1.0", window=tag)
self.update_idletasks()
tag_reqheight = tag.winfo_reqheight()
textarea_frame.configure(height=tag_reqheight + 2*self.TAG_ENTRY_PADY+2*self.textarea["borderwidth"])
# I add a hidden frame because I want the cursor centered including when there is no tag
self.textarea.window_create("1.0", window=Frame(self.textarea, height=tag_reqheight, width=0, borderwidth=0))
tag.destroy()
示例14: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self, list_=None, master=None, title=None):
'''Must have master, title is optional, li is too.'''
self.master = master
if self.master is not None:
self.top = Toplevel(self.master)
else:
return
self.v = None
if list_ is None or not isinstance(list_, list):
self.list = []
else:
self.list = list_[:]
self.top.transient(self.master)
self.top.grab_set()
self.top.bind("<Return>", self._choose)
self.top.bind("<Escape>", self._cancel)
if title:
self.top.title(title)
lf = Frame(self.top) #Sets up the list.
lf.pack(side=TOP)
scroll_bar = Scrollbar(lf)
scroll_bar.pack(side=RIGHT, fill=Y)
self.lb = Listbox(lf, selectmode=SINGLE)
self.lb.pack(side=LEFT, fill=Y)
scroll_bar.config(command=self.lb.yview)
self.lb.config(yscrollcommand=scroll_bar.set)
self.list.sort()
for item in self.list:
self.lb.insert(END, item) #Inserts items into the list.
bf = Frame(self.top)
bf.pack(side=BOTTOM)
Button(bf, text="Select", command=self._choose).pack(side=LEFT)
Button(bf, text="New", command=self._new).pack(side=LEFT)
Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)
示例15: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import pack [as 别名]
def __init__(self, master):
mainframe = Frame(master)
mainframe.pack()
self.quitb = Button(mainframe,
text="QUIT",
fg="red",
command=self.daquit)
self.quitb.pack(side=RIGHT)
self.runb = Button(mainframe,
text="Run 3color",
command=self.runapp)
self.runb.pack(side=LEFT)
self.launchb = Button(mainframe,
text="Open in Browser",
command=self.launchsite)
self.launchb.pack(side=LEFT)
self.stopb = Button(mainframe,
text="Stop 3color",
command=self.stopapp)
self.stopb.pack(side=TOP)