I am trying to create a window which consists of frame and a button(s) inside of it.
The problem I am facing is when I set the sizes of the frame, they are no longer valid when the label is added inside of this frame.
Only frame:
from tkinter import *
root = Tk()
root.resizable(False, False)
frame = Frame(root, bg="red", height=200, width=200)
frame.pack(side=LEFT, fill=BOTH)
root.mainloop()
It produces a window with red frame 200x200.
When I add a label inside, then the windows takes size of a label.
from tkinter import *
root = Tk()
root.resizable(False, False)
frame = Frame(root, bg="red", height=200, width=200)
frame.pack(side=LEFT, fill=BOTH)
z = Label(frame, bg="yellow", text='yellow label')
z.pack(side=LEFT, fill=BOTH)
root.mainloop()
How to make a frame with its original size and just add a label inside which will fit properly to the frame sizes?
I can achive this size by adding height and width to the label, but IMO the parent level should determine the size. What if I would like to have more than one label inside of frame - then each label should have sizes applied which is bad, specifing a size in the parent level seems to be more logic.
Thanks