All my option menu widgets are being updated together when I change the values of 1 option menu.
This is what I use to make all of the menus (self.var
is initialized as self.var = StringVar(master)
):
def makeMenu(self, name, items, r, c):
self.var.set(items[0])
name = OptionMenu(self, self.var, *items)
name.grid(row = r, column = c , padx = self.pad_x, pady = self.pad_y)
name.config( width = self.menu_width)
name.menu = Menu(name, tearoff = self.tear_off)
for i in range(len(items)):
name.menu.add_command(label = items[i])
return name
When I try to make a new menu and change the items, all of the other menus' items change to the new ones as well.
i.e. when I do this:
self.layout_menu = self.makeMenu("layout_menu", self.layout_sections,
self.layout_menu_row, self.layout_menu_col)
I really do not think that you need StringVar(master)
, you just need StringVar()