本文整理汇总了Python中ttk.Frame.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.pack方法的具体用法?Python Frame.pack怎么用?Python Frame.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Frame
的用法示例。
在下文中一共展示了Frame.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=GROOVE, borderwidth=5)
frame.pack(fill=BOTH, expand=1)
self.pack(fill = BOTH, expand = 1)
self.imageLabel = Label(frame, image = "")
self.imageLabel.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close")
closeButton.pack(side=RIGHT)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")]
option = OptionMenu(self, self.key, *options)
self.key.set(options[0])
option.pack(side="left")
spin = Spinbox(self, from_=0, to=1, increment=0.05)
self.val = spin.get()
spin.pack(side="left")
示例2: __init__
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
class binaryErosionApp:
def __init__(self, parent):
self.parent = parent
self.frame = Frame(self.parent)
self.parent.title("Binary Erosion")
self.initUI()
def initUI(self):
#Create 3x3 Grid
for columns in range(0, 3):
self.parent.columnconfigure(columns, pad = 14)
for rows in range(0, 3):
self.parent.rowconfigure(rows, pad = 14)
#Add Noise Options
binaryErosion1 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 1", command = self.binaryErosion1Clicked)
binaryErosion2 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 2", command = self.binaryErosion2Clicked)
binaryErosion1.grid(row = 1, column = 1, padx = 10, pady = 10, sticky = 'w')
binaryErosion2.grid(row = 1, column = 2, padx = 10, pady = 10, sticky = 'w')
self.frame.pack()
def binaryErosion1Clicked(self):
global _img, red, green, blue
structure = zeros((20, 20))
structure[range(20), range(20)] = 1.0
red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0)
green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0)
blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0)
for a in range(0, _img.shape[0]):
for b in range(0, _img.shape[1]):
_img[a, b, 0] = (red[a, b] * 255.0).astype('uint8')
_img[a, b, 1] = (green[a, b] * 255.0).astype('uint8')
_img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8')
updateImage()
def binaryErosion2Clicked(self):
global _img, red, green, blue
structure = zeros((20, 20))
structure[range(20), range(20)] = 1.0
red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0)
green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0)
blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0)
red = ndimage.binary_erosion(red, structure)
green = ndimage.binary_erosion(green, structure)
blue = ndimage.binary_erosion(blue, structure)
for a in range(0, _img.shape[0]):
for b in range(0, _img.shape[1]):
_img[a, b, 0] = (red[a, b] * 255.0).astype('uint8')
_img[a, b, 1] = (green[a, b] * 255.0).astype('uint8')
_img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8')
updateImage()
示例3: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Book downloader")
self.style = Style()
self.style.theme_use("default")
framesearch = Frame(self)
framesearch.pack(fill=BOTH)
search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15)
search_label.pack(side=LEFT)
self.search_entry = Entry(framesearch)
self.search_entry.pack(side=RIGHT, fill=X)
self.search_entry.bind("<Return>", self.searchHandler)
#self.search_entry.bind("<Key>", self.searchHandler)
framelist = Frame(self, relief=RAISED, borderwidth=1)
framelist.pack(fill=BOTH, expand=True)
self.lb = Listbox(framelist, height=30)
scrollbar = Scrollbar(framelist)
scrollbar.pack(side=RIGHT, fill=Y)
self.lb.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.lb.yview)
self.loadLibrary()
for b in self.book_list:
self.lb.insert(END, b[0])
self.lb.pack(fill=BOTH)
self.pack(fill=BOTH, expand=True)
DownButton = Button(self, text="Download", command=self.downloadAction)
DownButton.pack(side=RIGHT)
示例4: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=1)
#We create another Frame widget.
#This widget takes the bulk of the area.
#We change the border of the frame so that the frame is visible.
#By default it is flat.
self.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close")
closeButton.pack(side=RIGHT, padx=5, pady=5)
#A closeButton is created.
#It is put into a horizontal box.
#The side parameter will create a horizontal box layout, in which the button is placed to the right of the box.
#The padx and the pady parameters will put some space between the widgets.
#The padx puts some space between the button widgets and between the closeButton and the right border of the root window.
#The pady puts some space between the button widgets and the borders of the frame and the root window.
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
示例5: __init__
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def __init__(self, master, customers, payments, refresh):
Toplevel.__init__(self,master)
self.root = master
self.refresh = refresh
self.title("Check In")
self.iconname = "Check In"
self.name = StringVar() # variable for customer
self.customers = customers # customers object
self.payments = payments
self.names = []
self.workout = StringVar()
self.workouts = []
self.workouts_form = []
self.date = StringVar()
self.date.set(strftime("%m/%d/%Y"))
self.refresh_time = 15 # in minutes
self.output = '' # for the output label at the bottom
self.schedule = Schedule()
self.logger = Logger() #throws IOError if file is open
inf = Frame(self)
inf.pack(padx=10,pady=10,side='top')
Label(inf, text="Name:").grid(row=0,column=0,sticky=E,ipady=2,pady=2,padx=10)
Label(inf, text='Date:').grid(row=1,column=0,sticky=E,ipady=2,pady=2,padx=10)
Label(inf, text="Workout:").grid(row=2,column=0,sticky=E,ipady=2,pady=2,padx=10)
self.name_cb = Combobox(inf, textvariable=self.name, width=30,
values=self.names)
self.name_cb.grid(row=0,column=1,sticky=W,columnspan=2)
self.date_ent = Entry(inf, textvariable=self.date)
self.date_ent.grid(row=1,column=1,sticky=W)
self.date_ent.bind('<FocusOut>', self.update_workouts)
Button(inf,text='Edit', command=self.enable_date_ent).grid(row=1,column=2,sticky=E)
self.workout_cb = Combobox(inf, textvariable=self.workout, width=30,
values=self.workouts_form,state='readonly')
self.workout_cb.grid(row=2,column=1,sticky=W,columnspan=2)
self.log_btn=Button(inf,text="Log Workout",command=self.log,width=12)
self.log_btn.grid(row=3,column=1,columnspan=2,pady=4,sticky='ew')
stf = Frame(self)
stf.pack(padx=10,pady=10,fill='x',side='top')
self.scrolled_text = ScrolledText(stf,height=15,width=50,wrap='word',state='disabled')
self.scrolled_text.pack(expand=True,fill='both')
self.update_workouts()
self.update_names()
self.bind('<Return>',self.log)
self.name_cb.focus_set() # set the focus here when created
#disable the date field
self.disable_date_ent()
#start time caller
self.time_caller()
示例6: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Pycollect")
self.pack(fill=BOTH)
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
filemenu = Menu(menubar)
filemenu.add_command(label="Open", command=self.open_database)
filemenu.add_command(label="Exit", command=self.on_exit)
menubar.add_cascade(label="File", menu=filemenu)
frame1 = Frame(self)
frame1.pack(fill=X)
self.game_count = StringVar()
game_count_label = Label(frame1, textvariable=self.game_count).pack()
frame2 = Frame(self)
frame2.pack(fill=X, side=LEFT, expand=True)
self.game_list = Listbox(frame2)
self.game_list.pack(fill=Y, side=LEFT, expand=True)
# Events
self.bind('<<update_game_count>>', self.update_game_count)
self.bind('<<update_game_list>>', self.update_game_list)
示例7: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
#<standard set up>
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("default")
#</standard set up>
#if you put buttons here, it will initiate the buttons.
#then it will initiate the frame. You would get two columns.
#buttons appear in the second "lowered" area and not the raised frame.
#<adding an additional frame>
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand =1)
#</adding an additional frame>
#<standard self.pack>
self.pack(fill=BOTH, expand =1)
#</standard self.pack>
#<buttons are placed here>
closeButton = Button (self, text = "Close")
closeButton.pack(side=RIGHT, padx=5, pady =5)
okButton = Button(self, text = "OK")
okButton.pack(side=RIGHT)
示例8: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.pack(fill=BOTH, expand=1)
#create special frame for buttons at the top
frame = Frame(self)
frame.pack(fill=X)
search = Entry(frame)
def callback():
#create new window
main(Search.SearchFrontPage(search.get()))
b = Button(frame, text="Search", width=5, command=callback)
b.pack(side=RIGHT)
search.pack(side=RIGHT)
def login():
#change login credentials
self.credentials = reddituserpass.main()
self.parent.destroy()
login = Button(frame, text="Login", width=5, command=login)
login.pack(side=LEFT)
self.drawWindow()
示例9: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Mystery Room")
self.pack(fill=BOTH, expand = 1)
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=1)
#okButton = Button(self, text = "OK")
#okButton.place(x = self.width - 200, y = self.height - 100)
#quitButton = Button(self.parent, text = "QUIT", command = self.endCommand)
#quitButton.place(x = self.width - 100, y = self.height - 100)
scale = 0.75
self.wow_pic = Image.open("/home/pi/demo2/hd_1.jpg")
self.wow_pic = self.wow_pic.resize((self.width, self.height))
self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic)
self.label_wow_pic = Label(self, image = self.wow_pic_tk)
self.label_wow_pic.image = self.wow_pic_tk
self.label_wow_pic.place(x = 0, y = 0)
info_x = int(self.width*scale) + 20
示例10: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
#some aesthetic definitions
self.parent.title("Message Responder")
self.style = Style()
self.style.theme_use("classic")
#building frame
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
#adding some widgets
label = Label(frame, text = self.text, wraplength = 495, justify = LEFT)
label.pack()
self.textBox = Text(frame, height = 2, width = 495)
self.textBox.pack(side = BOTTOM)
#self.textBox.insert(END, '#enter ye comments here')
labelBox = Label(frame, text = "Actual Results:")
labelBox.pack(anchor = W, side = BOTTOM)
passButton = Button(self, text="PASS", command=self.btnClickedPass)
passButton.pack(side=RIGHT, padx=5, pady=5)
failButton = Button(self, text="FAIL", command=self.btnClickedFail)
failButton.pack(side=RIGHT)
示例11: __init__
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
self.geometry("550x550+450+150")
# the container is where we'll stack a bunch of frames
# on top of each other, then the one we want visible
# will be raised above the others
container = Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.protocol('WM_DELETE_WINDOW', self.leaveCallback) # root is your root window
self.frames = {}
for F in (StartPage, AboutPage, CreateServer, FindServer, ChooseType, GameWindow):
page_name = F.__name__
frame = F(container, self)
self.frames[page_name] = 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.show_frame("StartPage")
示例12: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
crawlVar = IntVar()
scanVar = IntVar()
dnsVar = IntVar()
emailVar = IntVar()
self.filename = StringVar()
self.parent.title("E-Z Security Audting")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, borderwidth=1)
frame.pack(side=TOP, fill=BOTH)
self.pack(side=TOP, fill=BOTH)
dnsButton = Checkbutton(self, text="DNS Recon", variable=dnsVar)
dnsButton.pack(fill=X)
scanButton = Checkbutton(self, text="Port Scan", variable=scanVar)
scanButton.pack(fill=X)
crawlButton = Checkbutton(self, text="Web Crawl", variable=crawlVar)
crawlButton.pack(fill=X)
emailButton = Checkbutton(self, text="Email Gathering", variable=emailVar)
emailButton.pack(fill=X)
lab = Label(self, width=15, text="Filename", anchor='w')
ent = Entry(self,textvariable=self.filename)
self.pack(side=TOP, fill=X, padx=5, pady=5)
lab.pack(side=LEFT)
ent.pack(side=RIGHT, fill=X)
示例13: documentation
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def documentation(version, w, h):
def _setdoc(evt):
w = evt.widget
index = int(w.curselection()[0])
doc = w.get(index)
textfield.config(state=NORMAL)
textfield.delete('1.0', END)
textfield.insert('1.0', docdic[doc])
textfield.config(state=DISABLED)
r = Toplevel()
w = int(w/2)
h = int(h/2)
r.geometry('{}x{}+{}+{}'.format(w, h, int(w/2), int(h/2)))
r.wm_title('Documentation accpy version {}'.format(version))
lf = Frame(r)
lf.pack(side=LEFT, fill=BOTH, expand=False)
rf = Frame(r)
rf.pack(side=RIGHT, fill=BOTH, expand=True)
docmenuopts = ['General',
'Lattice editor',
'Citation']
docmenu = Listbox(lf)
for entry in docmenuopts:
docmenu.insert(END, entry)
docmenu.pack(fill=BOTH, expand=True)
docmenu.bind('<<ListboxSelect>>', _setdoc)
scrollbar = Scrollbar(orient="vertical")
textfield = Text(rf, xscrollcommand=scrollbar.set)
textfield.pack(fill=BOTH, expand=True)
示例14: playar
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
class playar(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.filenm=None
self.pack(fill=BOTH, expand=1)
self.parent = parent
self.initplayer()
def initplayer(self):
self.videoFrame = Frame(self, width=800, height=480)
self.videoFrame.pack(side="top", fill="both", expand=True)
self.buttonframe = Frame(self, padding="2 2 11 11")
self.buttonframe.pack(side="bottom", fill="x", expand=True)
self.selectbutton = Button(self.buttonframe, text="Select")
self.selectbutton.grid(column=0, row=0, sticky=W)
self.playbutton = Button(self.buttonframe, text="Play").grid(column=1, row=0, sticky=W)
for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5)
self.buttonframe.rowconfigure(0, weight=1)
self.buttonframe.columnconfigure(0, weight=1)
self.buttonframe.columnconfigure(1, weight=1)
def setwh(self,w,h):
self.videoFrame.configure(width=w, height=h)
def quit(self):
print "QUIT CALLED"
pg.quit()
self.destroy()
示例15: initUI
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import pack [as 别名]
def initUI(self):
self.parent.title("Example")
self.pack(fill=BOTH, expand = 1)
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=1)
okButton = Button(self, text = "OK")
okButton.place(x = self.width - 200, y = self.height - 100)
quitButton = Button(self.parent, text = "QUIT")
quitButton.place(x = self.width - 100, y = self.height - 100)
scale = 0.75
self.wow_pic = Image.open("hd_1.jpg")
self.wow_pic = self.wow_pic.resize((int(self.width*scale), int(self.height*scale)))
self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic)
self.label_wow_pic = Label(self, image = self.wow_pic_tk)
self.label_wow_pic.image = self.wow_pic_tk
self.label_wow_pic.place(x = 10, y = 10)
info_x = int(self.width*scale) + 20
label_text_area = Tkinter.Label(self, text = "Message received:")
label_text_area.place(x = info_x, y = 10)
self.text_area = Tkinter.Text(self, height = 10, width = 40)
self.text_area.place(x = info_x, y = 30)