Error When Putting Widgets Into A Frame Which Is Inside A Frame. Tkinter - Python3
So the code below is a shortened version of what my actual code is. I'm having a problem when getting a widget to appear within a Frame which is placed within a Frame. So, basicall
Solution 1:
Your problem is due to creating your frame and aligning it in a single line of code.
When writing:
titleFrame = tk.Frame(self, relief='sunken').grid(row=0, column=0)
titleFrame
is the output of the .grid()
method, instead of the tk.Frame
you just created. So it cannot be used as a parent for future widgets.
In order to keep the reference to a widget, you have to separate widget creation from widget alignment:
titleFrame = tk.Frame(self, background='#f8f8ff', bd=1, relief='sunken')
titleFrame.grid(row=0, column=0, sticky='nsew', padx=2, pady=2)
titleLabel = tk.Label(titleFrame, text='TITLE')
titleLabel.grid(row=0,column=0, sticky='nsew', padx=2, pady=2)
Post a Comment for "Error When Putting Widgets Into A Frame Which Is Inside A Frame. Tkinter - Python3"