I got the following code for an OptionMenu
in tkinter
from another post on Stack Overflow:
variable = StringVar(master)
variable.set("one")
w = OptionMenu(master, variable, "one", "two", "three")
w.pack()
Now, if I wanted to put this OptionMenu
in a specific frame (say, frame1
), how should I edit this? I've tried doing this:
variable = StringVar(master)
variable.set("one")
w = OptionMenu(frame1, variable, "one", "two", "three")
w.grid(row = 4, column = 1)
and this:
variable = StringVar(master)
variable.set("one")
w = OptionMenu(master, variable, "one", "two", "three")
w.grid(row = 4, column = 1)
But in both cases, the program freezes and fails to load. Do you think this is an isolated issue with the code above, or is the code above fine which means it's something else with my program (which I can look over to fix)? Thank you.
grid
andpack
in the same frame. Please show us a minimal reproducible example.