Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Tkinter button have children?

I have the following code to create a button in Tkinter:

button = Button(self.parent_frame, width=100, height=100)
frame = Frame(button)
label = Label(frame, text="This is a button")
frame.pack(fill=BOTH, expand=1)
label.pack(fill=BOTH, expand=1)

When I hover my mouse over some parts of the button, the button rapidly resizes to the width of the window and then back to its initial size. Why does this happen? Is a Tkinter button not allowed to have children?

Note: I am not planning on using a frame inside a button, I am just asking this for hypothetical purposes. So instead of answers suggesting workarounds, I would prefer explanations as to why this happens.

like image 553
null Avatar asked Nov 17 '16 18:11

null


1 Answers

Theoretically, yes, a button can have children. I suspect the behavior is undefined for platforms that use native widgets (ie: OSX and Windows).

like image 127
Bryan Oakley Avatar answered Oct 08 '22 12:10

Bryan Oakley