This concerns Python and Tkinter.
I wish to have a Label widget display the word "Meow".
The Label widget should be the child of a Frame in a Tk window.
This seems simple, yet the code below does not work - nothing appears:
import tkinter as tk
class Options(tk.Frame):
def __init__(self, gui_parent):
super().__init__()
tk.Label(self, text="Meow").pack()
class Gui(tk.Tk):
def __init__(self):
super().__init__()
Options(self)
gui = Gui()
gui.mainloop()
I then experimented: if I change the Label widget to tk.Label(gui_parent, text="Meow").pack()
, the content of the window then appears. (However this is not the 'correct' behaviour, since I wish for the Label widget to be a direct child of the Frame widget, not of the Tk parent window.)
To my understanding, super().__init__()
should have instantiated a Frame. The Label widget should then be able to access the Frame via self
. This is not so.
Where have I gone wrong?