12.07.2015 Views

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

direction Normally, the menu will appear below themenubutton. Set this option to "left", "right",or "above" to change where menu appears relativeto the menubutton.disabled<strong>for</strong>eground The <strong>for</strong>eground color shown on this menubuttonwhen it is disabled.fontThe font used to display text on the button. SeeFonts, above.<strong>for</strong>egroundThe <strong>for</strong>eground color when the mouse is not overthe menubutton. May be abbreviated as fg.heightThe height of the menubutton in lines of text (notpixels!).a The default is to fit the menubutton’s sizeto its contents.highlightbackground Color of the focus highlight when the widget doesnot have focus.highlightcolor Color shown in the focus highlight when the widgethas the focus.highlightthickness Thickness of the focus highlight.imageTo make an image appear on this menubutton, setthis option to the image object. See Images, above.justifyThis option controls where the text is located whenthe text doesn’t fill the menubutton: LEFT (the default),CENTER, or RIGHT.menuTo associate the menubutton with a set of choices,set this option to the Menu object containing thosechoices. That menu object must have been createdby passing the associated menubutton to the constructoras its first argument. See below <strong>for</strong> anexample showing how to associate a menubuttonand menu.padxHow much space to leave to the left and right of thetext of the menubutton. Default is 1.padyHow much space to leave above and below the textof the menubutton. Default is 1.reliefNormally, menubuttons will have RAISED appearance,but you can set this option to FLAT, SUNKEN,RIDGE, or GROOVE relief.stateNormally, menubuttons respond to the mouse. Setthis option to DISABLED to gray out the menubuttonand make it unresponsive.textTo display text on the menubutton, set this optionto the string containing the desired text. Newlines(\n) within the string will cause line breaks.textvariable You can associate a control variable of classStringVar with this menubutton. Setting that controlvariable will change the displayed text. SeeControl variables, below.underlineNormally, no underline appears under the text onthe menubutton. To underline one of the characters,set this option to the index of that character.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: The Menubutton widget Page 39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!