0

how to refresh or change tkinter frame

I am working on python GUI application where i need to change only one perticular frame according to the user choices. in my gui i have 3 frames which divide screen into 3 main parts namely sidebar, navbar, ana main container. i just want to refresh main container according to the buttons of sidebar. i tried with *tkraise()* but its not working, following is my code, any suggestions how can we update only 1 frame? from tkinter import * from tkinter import ttk def sow(frame): frame.tkraise(aboveThis = frame3) print('button clicked') root = Tk() root.geometry('1366x768') root.resizable(0,0) #============== creating frames frame1 = Frame(root, height=50, background='lightblue') frame2 = Frame(root, width=250, background='lightblue') frame3 = Frame(root,width=1116,height=718, background='skyblue') frame4 = Frame(root,width=1116,height=718, background='blue') #============== packing frames frame1.pack(side=TOP, fill=X) frame2.pack(side=LEFT, fill=Y) frame3.pack(side=LEFT, fill=BOTH, padx=5,pady=5) frame4.pack(side=LEFT, fill=BOTH, padx=5,pady=5) label1 = Label(frame3) label1.place(relx=0.45, rely=0.3) label1.configure(text="""this is main frame""",relief="flat", background='skyblue', font="-family {Poppins} -size 18") button1 = Button(frame3) button1.place(relx=0.5, rely=0.5, width=76, height=23) button1.configure(relief="flat",text="""main frame""",command= lambda: sow(frame4)) button2 = Button(frame2) button2.place(relx=0.35, rely=0.45, width=76, height=23) button2.configure(relief="flat",text="""btn1""",command= lambda: sow(frame4)) button3 = Button(frame2) button3.place(relx=0.35, rely=0.6, width=76, height=23) button3.configure(relief="flat",text="""btn 2""",command= lambda: sow(frame4)) root.mainloop()

5th Jul 2021, 6:33 AM
Vishvajit Bhagat
2 Respuestas
+ 2
This should help you. Similar concept, but it's switches between 3 pages (frames) on the main tk frame. https://pythonprogramming.net/change-show-new-frame-tkinter/
5th Jul 2021, 8:00 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
I am new to python and not very familiar with oops concepts but I will try your solution Thanks
5th Jul 2021, 8:11 AM
Vishvajit Bhagat