Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a frame inside a frame? [closed]

Tags:

python

tkinter

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 ?

like image 460
user3615538 Avatar asked Feb 14 '23 01:02

user3615538


1 Answers

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()    
like image 124
Ashok Avatar answered Feb 23 '23 08:02

Ashok