python tkinter option menu help - object has no attribute '_root' python tkinter option menu help - object has no attribute '_root' tkinter tkinter

python tkinter option menu help - object has no attribute '_root'


This is where the problems are.

self.fumeEntry = StringVar(self)self.fumeEntryOM = OptionMenu(self, self.fumeEntryOM, '1', '2', '3')

The master or parent of these widgets must be a Tkinter widget. self (referring to MyApp class) is just a class and not a Tkinter widget.

You have two options available to you.

  1. Make MyApp a subclass of the Tk() widget

    class MyApp(Tk):# extra code goes here
  2. Make the StringVar and OptionMenu slaves of self.master.

    self.fumeEntry = StringVar(self.master)# extra codeself.fumeEntryOM = OptionMenu(self.master, self.fumeEntry, "1", "2", "3")


Your option menu isn't being initialised with the variable. You have:

self.fumeEntryOM = OptionMenu(self, self.fumeEntryOM, '1', '2', '3')

Should be:

self.fumeEntryOM = OptionMenu(self, self.fumeEntry, '1', '2', '3')