Menu Attributes

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 27.  Buttons and Menus


A menu has a few global attributes, and then each menu entry has many button-like attributes that describe its appearance and behavior. Table 27-5 specifies the attributes that apply globally to the menu, unless overridden by a per-entry attribute. The table uses the X resource names, which may have a capital at interior word boundaries. In Tcl commands, use all lowercase and a leading dash.

Table 27-5. Menu attribute resource names.
activeBackgroundBackground color when the mouse is over a menu entry.
activeForegroundText color when the mouse is over a menu entry.
activeBorderWidthWidth of the raised border around active entries.
backgroundThe normal background color for menu entries.
borderWidthWidth of the border around all the menu entries.
cursorCursor to display when mouse is over the menu.
disabledForegroundForeground (text) color when menu entries are disabled.
fontDefault font for the text.
foregroundForeground color. (Also fg).
postCommandTcl command to run just before the menu is posted.
selectColorColor for selector in check and radio type entries.
takeFocusControl focus changes from keyboard traversal.
tearOffTrue if menu should contain a tear-off entry.
tearOffCommandCommand to execute when menu is torn off. Two arguments are added: the original menu and the new tear-off.
type(Read-only) normal, menubar, or tearoff. (Tk 8.0).

Table 27-6 describes the attributes for menu entries, as you would use them in a Tcl command (i.e., all lowercase with a leading dash.) The attributes for menu entries are not supported directly by the resource database. However, Example 28-6 on page 411 describes how you can use the resource database for menu entries.

Table 27-6. Attributes for menu entries.
-activebackgroundBackground color when the mouse is over the entry.
-activeforegroundForeground (text) color with mouse is over the entry.
-acceleratorText to display as a reminder about keystroke binding.
-backgroundThe normal background color.
-bitmapA bitmap to display instead of text.
-columnbreakPuts the entry at the start of a new column. (Tk 8.0).
-commandTcl command to invoke when entry is invoked.
-fontDefault font for the text.
-foregroundForeground color. (Also fg).
-hidemarginSuppresses the margin reserved for button indicators. (Tk 8.0).
-imageImage to display instead of text or bitmap.
-labelText to display in the menu entry.
-justifyText justification: center, left, or right.
-menuMenu posted when cascade entry is invoked.
-offvalueVariable value when check entry is not selected.
-onvalueValue for Tcl variable when check entry is selected.
-selectcolorColor for selector: check and radio entries.
-stateThe state: normal, active, or disabled
-underlineIndex of text character to underline.
-valueValue for Tcl variable when radiobutton entry is selected.
-variableTcl variable associated with the check or radio entry.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net