python - User interface optimization when using pack -


i have code, creates ui this.
enter image description here

i want page up/down buttons next page 1 label couldn't managed that. way know pack side option , not working well.

second thing is, scrollbar should in listbox. know, need create canvas frame in it. embed both listbox , scrollbar them couldn't either.

this code.

class interface(tk.frame):     def __init__(self,den):         self.pa_nu = 0  ##page number. both used in labeling , result slicing         self.lbl1 = tk.label(den, text="keyword")         self.lbl2 = tk.label(den, text="page %d" %(self.pa_nu+1))         self.ent1 = tk.entry(den, takefocus=true)         self.btn1 = tk.button(den, text="search", command=self.button1)         self.btn2 = tk.button(den, text="page up", command=self.page_up)         self.btn3 = tk.button(den, text="page down", command=self.page_down)          scrollbar = tk.scrollbar(den)         scrollbar.pack(side=right, fill=y)         self.lst1 = tk.listbox(den, selectmode="single", width="40", yscrollcommand=scrollbar.set)         self.lst1.bind("<double-button-1>", self.open_folder)         scrollbar.config(command=self.lst1.yview)          self.lbl1.pack(side="top")         self.ent1.pack()         self.btn1.pack(side="top")         self.btn2.pack(side="right")         self.btn3.pack(side="left")         self.lbl2.pack(side="bottom",padx=65)         self.lst1.pack(fill=both)      def button1(self):              pass #some stuff here      def page_up(self):         pass #some stuff here      def page_down(self):         pass #some stuff here      def list_fill(self,i):         pass #some stuff here      def open_folder(self,event):         pass #some stuff here 

there 3 geometry managers in tkinter: place (absolute position), pack (good line of widgets, or simple layout) , grid (complex layout).

grid worth looking layout working on. if keep going pack, usual way achieve complex layout use intermediate frames. instance, in following picture, widgets in frame1 packed vertically, , horizontally in frame2.

enter image description here diagram draw.io

regarding scrollbar, usual way again use intermediate frame (no need canvas). here snippet (copied http://effbot.org/zone/tkinter-scrollbar-patterns.htm#listbox)

frame = frame(root, bd=2, relief=sunken)  scrollbar = scrollbar(frame) scrollbar.pack(side=right, fill=y)  listbox = listbox(frame, bd=0, yscrollcommand=scrollbar.set) listbox.pack()  scrollbar.config(command=listbox.yview)  frame.pack() #or others... 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -