0

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.

1

1 Answer 1

0

Have you tried:

variable = StringVar(master)
variable.set("one")
w = OptionMenu(frame1, variable, "one", "two", "three")
w.pack()

If it works it is because you are mixing pack() and grid() geometry managers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.