Using Tkinter i have created 5 frames, each containing
- frame0 -
label
,Entry box
and abutton(Enter)
- frame1 -
label
andlist box
at the left side - frame2 -
2 buttons(select & unselect)
at the center - frame3 -
label
andlistbox
at the right side frame4 -
2 buttons(done & clear)
---------------------------------------- | frame0 | ---------------------------------------- | | | | | frame1 | frame2 | frame3 | | | | | ---------------------------------------- | frame4 | ----------------------------------------
This is my code:
from Tkinter import *
def toplevelwin():
def clear():
return
def select():
return
def unselect():
return
def done():
return
def enter():
return
window = Toplevel()
frame0 = Frame(window)
frame0.grid(row=0, column=0, sticky=W, padx=5, pady=5, columnspan=2)
frame0.grid_columnconfigure(1,weight=2)
lblentry = Label(frame0, text="Entery Box:")
lblentry.grid(row=0, column=0, sticky=W)
entrybx = Entry(frame0)
entrybx.grid(row=1,column=0,sticky=N+S+E+W, columnspan=2)
entrybt = Button(frame0, text=' Enter ', command=enter)
entrybt.grid(row=1,column=2,sticky=N+W, padx=3)
frame1 = Frame(window)
frame1.grid(row=1, column=0, sticky=E+W, padx=5, pady=5)
lblshow_lst = Label(frame1, text="List Box 1:")
lblshow_lst.grid(row=0,sticky=W)
show_lst = Listbox(frame1)
show_lst.grid(row=1,sticky=W)
frame2 = Frame(window)
frame2.grid(row=1, column=1, sticky=W)
frame2.grid_columnconfigure(1,weight=1)
selbtn = Button(frame2, text='Select', command=select)
selbtn.grid(row=0, padx=5, sticky=E+W)
selbtn.grid_columnconfigure(1,weight=1)
uselbtn = Button(frame2, text='Unselect', command=unselect)
uselbtn.grid(row=1, padx=5, sticky=E+W)
uselbtn.grid_columnconfigure(1,weight=1)
frame3 = Frame(window)
frame3.grid(row=1, column=2, sticky=W, padx=5, pady=5)
lblsel_lst = Label(frame3, text="List Box 2:")
lblsel_lst.grid(row=0,sticky=W)
sel_lst = Listbox(frame3)
sel_lst.grid(row=1, column=0, sticky=W)
frame4 = Frame(window)
frame4.grid(row=2, column=0, sticky=E, padx=5, pady=5)
Button(frame4, text=' Done ', command=done).grid(row=0, column=0, padx=7 ,pady=2)
Button(frame4, text='Clear', command=clear).grid(row=0,column=1, padx=7,pady=2)
window.wait_window(window)
root = Tk()
toplevelwin()
root.mainloop()
And this is how my window looks now:
My Question is:
- How do i expand
frame0
uptillframe3
. ie, i want theentry box
to extend till frame3's end having thebutton(enter)
to its right side as it is. - And i want the
bottom frame's
button(done and clear) to be placed on the right side of the window
Tries:
i tried to increase the size of the entry widget, which in turn pushed frame2 and frame3 to the right side.
used
sticky=N+S+W+E
, which pushed it to the center of the windowalso did tried
sticky=W
for the bottom frame containing 2 buttons. They moved to the center but not right