user4772964
user4772964

Reputation:

Tkinter: nested LabelFrame (s) not shown

I want to split a LabelFrame into two label frames. So first, I created an other LabelFrame and tested if it displays well. But no, it is not displayed.

But when I change childLabelFrame to a simple Label or a simple Frame I see it displayed well.

I read some similar questions such as this one, but I did not do those errors in my case.

mainLabelFrame=LabelFrame(parent,text="Description:",padx=20,pady=20,200, width=400,relief=RIDGE)          
childLabelFrame=LabelFrame(mainLabelFrame,text="Help",relief=RIDGE)
childLabelFrame.grid(row=0,column=0)    
mainLabelFrame.grid(row=3,column=0,columnspan=3,sticky=E+W)

How to resolve this ?

Upvotes: 1

Views: 2999

Answers (1)

tobias_k
tobias_k

Reputation: 82899

It seems like childLabelFrame has zero size and thus is not drawn. Indeed, both childLabelFrame.winfo_width() and childLabelFrame.winfo_height() return 1.

It is drawn correctly if

  • you specify a size, like childLabelFrame = LabelFrame(mainLabelFrame, text="Help", height=100, width=200), or
  • you add something inside the child label frame, e.g. Label(childLabelFrame, text="label").grid().

Upvotes: 3

Related Questions