tkinter Option Menu Is missing
You need to use the pack()
method on your Frame
in init, otherwise the argument self
within your OptionMenu
doesn't refer to an existing Frame
.
Try this:
class WMGUI(tk.Frame): ''' A GUI for wm ''' def __init__(self, parent=None, *, title='WM'): if parent is None: parent = tk.Tk() tk.Frame.__init__(self, parent) self.parent = parent self.pack() #packs the Frame self.initUI(title) def initUI(self, title): """ do not call from outside of class """ self.parent.title(title) # make game_menu game_menu_var = tk.IntVar() game_menu_var.set(1) self.game_menu = tk.OptionMenu(self, game_menu_var, 1, 2 , 3) self.game_menu.pack(side="left")
Alternatively, the parent widget is self.parent
, so you could make that the master of self.game_menu:
self.game_menu = tk.OptionMenu(self.parent, game_menu_var, 1, 2 , 3)