gtk.MenuItemthe widget used for an item in menusSynopsisgtk.MenuItemgtk.Itemgtk.MenuItemlabelNoneuse_underlineTrueset_submenusubmenuget_submenuremove_submenuselectdeselectactivatetoggle_size_requesttoggle_size_allocateallocationset_right_justifiedright_justifiedget_right_justifiedset_accel_pathaccel_pathget_accel_pathset_labellabelget_labelset_use_underlinesettingget_use_underlineAncestry+-- gobject.GObject
+-- gtk.Object
+-- gtk.Widget
+-- gtk.Container
+-- gtk.Bin
+-- gtk.Item
+-- gtk.MenuItem
Implemented Interfacesgtk.MenuItem
implements
gtk.Buildableatk.ImplementorIFacegtk.MenuItem Propertiesgtk.Object Propertiesgtk.Widget Propertiesgtk.Container Properties
"accel-path"Read-WriteSets the accelerator path of the menu item, through
which runtime changes of the menu item's accelerator caused
by the user can be identified and saved to persistant storage.
Default value: None.
Available in GTK+ 2.14.
"label"Read-WriteThe text for the child label.
Available in GTK+ 2.16.
"right-justified"Read-WriteSets whether the menu item appears justified at the
right side of a menu bar.
Default value: False.
Available in GTK+ 2.14.
"submenu"Read-WriteThe submenu attached to the menu item, or
None if it has none. This
property is available in GTK+ 2.12 and above."use-underline"Read-WriteTrue if underlines in the text
indicate mnemonics.
Available in GTK+ 2.16.
"arrow-scaling"ReadAmount of space used up by arrow, relative to the menu item's font size.
Allowed values: [0,2].
Default value: 0.8"arrow-spacing"ReadSpace between label and arrow. Allowed values: >= 0.
Default value: 10"horizontal-padding"ReadPadding to left and right of the menu item. Allowed
values: >= 0. Default value: 3"selected-shadow-type"ReadThe shadow type when the item is selected. Default
value: gtk.SHADOW_NONE"toggle-spacing"ReadSpace between icon and label. Allowed values: >= 0.
Default value: 5"width-chars"ReadThe minimum desired width of the menu item in characters.
Allowed values: >= 0. Default value: 12.
Available in GTK+ 2.14.
gtk.MenuItem Signal Prototypesgobject.GObject Signal Prototypesgtk.Object Signal Prototypesgtk.Widget Signal Prototypesgtk.Container Signal Prototypesgtk.Item Signal Prototypes"activate"callbackmenuitemuser_param1..."activate-item"callbackmenuitemuser_param1..."toggle-size-allocate"callbackmenuitemallocationuser_param1..."toggle-size-request"callbackmenuitemrequisitionuser_param1...DescriptionThe gtk.MenuItem
widget implements the appearance and behavior of menu items. The gtk.MenuItem and
its derived widget subclasses are the only valid children of menus.When menu items are selected and activated by a user they
can:display a popup menu if they have an associated
submenuinvoke an associated function or methodAs a gtk.MenuItem is a
subclass of gtk.Bin it can hold any
valid child widget.Constructorgtk.MenuItemlabelNoneuse_underlineTruelabel :a string to be used as the text of the menu item
or Noneuse_underline :if True, an underscore in the
label text indicates the next character should be underlined and used for the
mnemonic accelerator key if it is the first character so
marked. Available in PyGTK 2.4 and above.Returns :a new gtk.MenuItem
widgetCreates a new gtk.MenuItem
widget and sets the text of the menu item label to the value of
label. If label is
None no label is created for the menu item. The text of
label is parsed for underscore characters that indicate that the next
character is a mnemonic accelerator.In PyGTK 2.4 and above the use_underline
parameter is available and defaults to True. If
use_underline is set to False the
label text will not be parsed for mnemonic characters.Methodsgtk.MenuItem.set_submenuset_submenusubmenusubmenu :the menu to use as the
submenuThe set_submenu() method sets the menu
specified by submenu as the submenu for the menu
item.gtk.MenuItem.get_submenuget_submenuReturns :the submenu for this menu item, or
None if there is no submenu.The get_submenu() method returns the
submenu widget associated with this menu item. If there is no submenu this
method returns None. See set_submenu().gtk.MenuItem.remove_submenuremove_submenuThe remove_submenu() method removes the
submenu associated with the menu item.gtk.MenuItem.selectselectThe select() method emits the "select"
signal on the menu item.gtk.MenuItem.deselectdeselectThe deselect() method emits the
"deselect" signal on the menu item.gtk.MenuItem.activateactivateThe activate() method emits the
"activate" signal on the menu item.gtk.MenuItem.toggle_size_requesttoggle_size_requestReturns :the size requisitionThis method is available in PyGTK 2.4 and above.The toggle_size_request() method emits
the "toggle-size-request" signal on the menuitem and returns the size
requested for the menuitem.gtk.MenuItem.toggle_size_allocatetoggle_size_allocateallocationallocation :the allocation size for the menu
itemThe toggle_size_allocate() method emits
the "toggle-size-allocate" signal on the menu item.gtk.MenuItem.set_right_justifiedset_right_justifiedright_justifiedright_justified :if True the menu item will
appear at the far right if added to a menu bar.The set_right_justified() method sets
the justification of the menu item according to the value of
right_justified. If
right_justified is True the menu
item will appear at the right side of a menu bar. If the widget layout is
reversed for a right-to-left language like Hebrew or Arabic,
right-justified-menu-items appear on the left.gtk.MenuItem.get_right_justifiedget_right_justifiedReturns :True if the menu item will
appear at the far right if added to a menu bar.The get_right_justified() method gets
the justification of the menu item. If True the menu item
appears justified at the right side of the menu bar.gtk.MenuItem.set_accel_pathset_accel_pathaccel_pathaccel_path :the accelerator path, corresponding to this
menu itemThe set_accel_path() method sets the
accelerator path on the menu item. The accelerator path provides access to
the menu item's accelerator allowing user changes to be identified and saved
to persistent storage. See also the gtk.Menu.set_accel_path()
method for a more convenient variant of this function. This method is a
convenience wrapper that handles calling gtk.Widget.set_accel_path()
with the appropriate accelerator group for the menu item.gtk.MenuItem.get_accel_pathget_accel_pathReturns :the accelerator path corresponding to this menu
item's functionality, or None if not set
The get_accel_path() method gets the accelerator
path that was previously set on menu_item.
gtk.MenuItem.set_labelset_labellabellabel :the text you want to set.This method is available in PyGTK 2.16 and above.The set_label() method sets the text
specified by label on the menu_item label .gtk.MenuItem.get_labelget_labelReturns :The text in the menu_item label.This method is available in PyGTK 2.16 and above.The get_label() method gets the text in the menu_item label.gtk.MenuItem.set_use_underlineset_use_underlinesettingsetting :True if underlines in the text indicate mnemonics.This method is available in PyGTK 2.16 and above.The set_use_underline() method gets whether an underline in the text
indicates the next character should be used for the mnemonic accelerator key.gtk.MenuItem.get_use_underlineget_use_underlineReturns :True if an embedded underline in the label indicates the mnemonic accelerator key.This method is available in PyGTK 2.16 and above.The get_use_underline() method checks if an underline in the text indicates
the next character should be used for the mnemonic accelerator key.SignalsThe "activate" gtk.MenuItem Signalcallbackmenuitemuser_param1...menuitem :the menuitem that received the
signaluser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)The "activate" signal is emitted when the menu item is
activated.The "activate-item" gtk.MenuItem Signalcallbackmenuitemuser_param1...menuitem :the menuitem that received the
signaluser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)The "activate-item" signal is emitted when the menu item is
activated, but also if the menu item has a submenu. For normal applications,
the relevant signal is "activate".The "toggle-size-allocate" gtk.MenuItem Signalcallbackmenuitemallocationuser_param1...menuitem :the menuitem that received the
signalallocation :the size allocation for the
menuitemuser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)The "toggle-size-allocate" signal is emitted when the size
allocation is changed.The "toggle-size-request" gtk.MenuItem Signalcallbackmenuitemrequisitionuser_param1...menuitem :the menuitem that received the
signalrequisition :the pointer to the location to put the size
requestuser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)The "toggle-size-request" signal is emitted when a new size
request is needed.