Changing the font size of anOptionMenu widget
rantingrickjohnson at gmail.com
Fri Jan 25 06:57:00 CET 2013
Ignoring the fact that the Tkinter.Optionmenu is by far the worst widget in the toolkit, not to mention that the whole idea of "Tkinter X_Variables" was a poor attempt to reuse code at the expense destroying the simple and intuitive interface of "get" and "set"; here is your answer:
## START CODE ##
from Tkinter import *
master = Tk()
variable = StringVar(master)
variable.set("one") # default value
optMenu = OptionMenu(master, variable, "one", "two", "three")
# Get the menu
menu = optMenu.nametowidget(optMenu.menuname)
## END CODE ##
PS: You could have probably intuited the answer yourself if you used the dir() function on "w". Of course you probably would have expected the Optionmenu to have a reference to the submenu. It does, however not a direct reference.
PPS: Or, if you prefer information overload you could have called "help(w)".
More information about the Python-list