How can i create a frame inside a frame in python using Tkinter and then pack a button in one frame and when i press the button the ouput will be given on the second frame ?
We can add a frame inside a frame. Below code should achieve it.
import Tkinter
tk = Tkinter.Tk()
frame1 = Tkinter.Frame(tk, height = 100, width = 100, bg = "WHITE", borderwidth=2)
frame2 = Tkinter.Frame(frame1, height = 100, width = 100, bg = "RED", borderwidth=2)
frame1.pack()
frame2.pack()
label = Tkinter.Label(frame2, text = "Label") #Receive a callback from button here
label.pack()
button = Tkinter.Button(frame1,text="Button") #Send some action to Label here
button.pack()
tk.mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With