I have two OptionMenu widgets in the simple pieces of code shown below:
variable = StringVar(win1)
variable.set(number(number2))
type = OptionMenu(win1, variable, "None", "Clear", "Dark", "Heavy", )
type.grid(row=i, column=3, sticky="nsew", padx=1, pady=1)
variableunit = StringVar(win1)
variableunit.set(unit)
unit = OptionMenu(win1, variableunit, "colour", "shade")
unit.grid(row=i, column=5, sticky="nsew", padx=1, pady=1)
I have tried traces with a callback function and so far hasn’t worked. I would like to link when “Heavy” is chosen in the first menu, the second menu is always “colour”. For the rest of the choices, the second menu must always be a default of “shade” but can be changed.
I would be grateful is anyone could help me. I’ve already looked at the effbot site with variables and traces but am still stuck.
It’s not exactly clear what you want, but I think this should do it.
When “Heavy” is selected in the first menu, “colour” is selected in the second one and that menu is disabled (can’t select anything else). When something else is selected in the first menu, the second one goes to “mm” and is enabled again.