gtk.Actionan action which can be triggered by a menu or toolbar
item (new in PyGTK 2.4)Synopsisgtk.Actiongobject.GObjectgtk.Actionnamelabeltooltipstock_idactivateblock_activateblock_activate_fromproxyconnect_acceleratorconnect_proxyproxycreate_iconicon_sizecreate_menucreate_menu_itemcreate_tool_itemdisconnect_acceleratordisconnect_proxyproxyget_accel_pathget_giconget_icon_nameget_is_importantget_labelget_nameget_proxiesget_visibleget_short_labelget_sensitiveget_stock_idget_tooltipget_visible_horizontalget_visible_verticalis_sensitiveis_visibleget_always_show_imageset_always_show_imagealways_showset_accel_groupaccel_groupset_accel_pathaccel_pathset_giconiconset_icon_nameicon_nameset_is_importantis_importantset_labellabelset_menu_item_typevisibleset_sensitivesensitiveset_short_labelshort_labelset_stock_idstock_idset_tool_item_typevisibleset_tooltiptooltipset_visible_horizontalvisible_horizontalset_visible_verticalvisible_verticalset_visiblevisibleunblock_activateunblock_activate_fromproxyAncestry+-- gobject.GObject
+-- gtk.Action
Implemented Interfacesgtk.Action
implements
gtk.Buildablegtk.Action Properties
"action-group"Read-WriteThe gtk.ActionGroup
this gtk.Action is
associated with, or None (for internal use)."always-show-image"Read-WriteIf True, the action's menu item proxies will ignore the "gtk-menu-images"
setting and always show their image, if available. Use this if the menu item would be useless or
hard to use without their image."hide-if-empty"Read-WriteIf True, empty menu proxies for this
action are hidden."gicon"Read-Write
The gio.Icon displayed in the
gtk.Action.
Note that the stock icon is preferred, if the "stock-id" property holds the id of an existing stock icon.
This is an appearance property and thus only applies if "use-action-appearance" is True.
This property is available in GTK+ 2.16 and above.
"icon-name"Read-Write
The name of the icon from the icon theme.
Note that the stock icon is preferred, if the "stock-id" property holds the id of an existing stock icon
and the gio.Icon is preferred if
the "gicon" property is set.
This is an appearance property and thus only applies if "use-action-appearance" is True.
This property is available in GTK+ 2.10 and above.
"is-important"Read-WriteIf True, gtk.ToolItem
proxies for this action show text in
gtk.TOOLBAR_BOTH_HORIZ mode."label"Read-WriteThe label used for menu items and buttons that activate
this action."name"Read-Write-Construct OnlyA unique name for the action."sensitive"Read-WriteIf True, the action is
enabled."short-label"Read-WriteA shorter label that may be used on toolbar
buttons."stock-id"Read-WriteThe stock icon displayed in widgets representing this
action."tooltip"Read-WriteA tooltip for this action."visible"Read-WriteIf True, the action is
visible."visible-horizontal"Read-WriteIf True, the toolbar item is
visible when the toolbar is in a horizontal orientation."visible-overflown"Read-Write
If True, toolitem proxies for this
action are represented in the toolbar overflow menu.
This property is available in GTK+ 2.6 and above.
"visible-vertical"Read-WriteIf True, the toolbar item is
visible when the toolbar is in a vertical orientation.
gtk.Action Signal Prototypesgobject.GObject Signal Prototypes"activate"callbackactionuser_param1...DescriptionThis widget is available in PyGTK 2.4 and above.A gtk.Action
represents operations that the user can perform, along with some information
how it should be presented in the interface. Each gtk.Action provides
methods to create icons, menu items and toolbar items representing
itself.As well as the callback that is called when the action gets
activated, the following also gets associated with the action:a name (not translated, for path lookup)a label (translated, for display)an acceleratorwhether the label indicates a stock ida tooltip (optional, translated)a toolbar label (optional, shorter than label)The action will also have some state information:visible (shown/hidden)sensitive (enabled/disabled)Apart from regular actions, there are toggle actions, which can be
toggled between two states and radio actions, where only one in a group
can be in the "active" state. Other actions can be implemented as gtk.Action
subclasses.Each gtk.Action can have
one or more proxy menu items, toolbar buttons or other proxy
widgets. Proxies mirror the state of the action (text label, tooltip, icon,
visible, sensitive, etc), and should change when the action's state
changes. When the proxy is activated, it should activate its action. Constructorgtk.Actionnamelabeltooltipstock_idname :a unique name for the gtk.Actionlabel :the label displayed in menu items and on
buttonstooltip :a tooltip for the actionstock_id :the stock icon to display in widgets
representing the actionReturns :a new gtk.ActionThis constructor is available in PyGTK 2.4 and above.Creates a new gtk.Action
object. To add the action to a gtk.ActionGroup
and set the accelerator for the action, call the gtk.ActionGroup.add_action_with_accel().Methodsgtk.Action.block_activateblock_activateThis method is available in PyGTK 2.16 and above.
The block_activate() method disable activation signals from the action
This is needed when updating the state of your proxy
gtk.Activatable
widget could result in calling
gtk.Action.activate(),
this is a convenience function to avoid recursing in those cases (updating toggle state for instance).
gtk.Action.get_giconget_giconReturns :The action's gio.Icon
if one is set.This method is available in PyGTK 2.16 and above.
The get_gicon() method gets the
gio.Icon of action.
gtk.Action.get_icon_nameget_icon_nameReturns :the icon name.
This method is available in PyGTK 2.16 and above.
The get_icon_name() method gets the icon name
of action.
gtk.Action.get_is_importantget_is_importantReturns :whether action is important, returning
True if it is.
This method is available in PyGTK 2.16 and above.
The get_is_important() method checks whether
action is important or not.
gtk.Action.get_labelget_labelReturns :the label text.
This method is available in PyGTK 2.16 and above.
The get_label() method gets the label text of action.
gtk.Action.get_nameget_nameReturns :the name of the action.This method is available in PyGTK 2.4 and above.The get_name() method returns the value
of the "name" property containing the name of the action.gtk.Action.get_short_labelget_short_labelReturns :the short label text.
This method is available in PyGTK 2.16 and above.
The get_short_label() method gets the short label text of action.
gtk.Action.get_tooltipget_tooltipReturns :the tooltip text.
This method is available in PyGTK 2.16 and above.
The get_tooltip() method gets the tooltip text of action.
gtk.Action.get_visible_horizontalget_visible_horizontalReturns :whether action is visible when horizontal.
This method is available in PyGTK 2.16 and above.
The get_visible_horizontal() method gets whether
action is visible when horizontal
gtk.Action.get_visible_verticalget_visible_verticalReturns :whether action is visible when vertical.
This method is available in PyGTK 2.16 and above.
The get_visible_vertical() method gets whether
action is visible when vertical.
gtk.Action.get_stock_idget_stock_idReturns :the stock id.
This method is available in PyGTK 2.16 and above.
The get_stock_id() method gets the stock id of action.
gtk.Action.is_sensitiveis_sensitiveReturns :True if the action and its
associated action group are both sensitive.This method is available in PyGTK 2.4 and above.The is_sensitive() method returns
True if the action is effectively sensitive i.e. both the
gtk.Action and
its associated gtk.ActionGroup
are sensitive.gtk.Action.get_sensitiveget_sensitiveReturns :True if the action itself
is sensitive.This method is available in PyGTK 2.4 and above.The get_sensitive() method returns the
value of the "sensitive" property. If "sensitive" is True
the action itself is sensitive. Note that this doesn't necessarily mean
effective sensitivity. See the is_sensitive()
method for more information.gtk.Action.is_visibleis_visibleReturns :True if the action and
its associated action group are both visible.This method is available in PyGTK 2.4 and above.The is_visible() method returns
True if the action is effectively visible i.e. both the
gtk.Action and
its associated gtk.ActionGroup
as visible.gtk.Action.get_visibleget_visibleReturns :True if the action itself
is visible.This method is available in PyGTK 2.4 and above.The get_visible() method returns the
value of the "visible" property. If "visible" is True the
gtk.Action
itself is visible. Note that this doesn't necessarily mean effective
visibility. See the is_visible()
method for more information.gtk.Action.activateactivateThis method is available in PyGTK 2.4 and above.The activate() method emits the
"activate" signal on the gtk.Action, if it
isn't insensitive. This gets called by the proxy widgets when they get
activated. It can also be used to manually activate an action.gtk.Action.create_iconcreate_iconicon_sizeicon_size :the size of the icon that should be
created.Returns :a widget that displays the icon for this
action.This method is available in PyGTK 2.4 and above.The create_icon() method creates and
returns a gtk.Image with the
size specified by size from the icon contained in the
"stock-id" property if it exists. The value of size
must be one of:gtk.ICON_SIZE_MENUgtk.ICON_SIZE_SMALL_TOOLBARgtk.ICON_SIZE_LARGE_TOOLBARgtk.ICON_SIZE_BUTTONgtk.ICON_SIZE_DNDgtk.ICON_SIZE_DIALOGThis method is intended for use by gtk.Action
implementations to create icons displayed in the proxy widgets.gtk.Action.create_menucreate_menuReturns :the menu item provided by the action, or
None.This method is available in PyGTK 2.12 and above.
If action provides a gtk.Menu.
widget as a submenu for the menu item or the toolbar item it creates, create_menu() method
returns an instance of that menu.
gtk.Action.create_menu_itemcreate_menu_itemReturns :a menu item connected to the
action.This method is available in PyGTK 2.4 and above.The create_menu_item() method creates
and returns a menu item widget that proxies for the gtk.Action.gtk.Action.create_tool_itemcreate_tool_itemReturns :a tool item connected to the
action.This method is available in PyGTK 2.4 and above.The create_tool_item() method creates
and returns a tool item widget that proxies for the gtk.Action.gtk.Action.connect_proxyconnect_proxyproxyproxy :the proxy widgetThis method is available in PyGTK 2.4 and above.The connect_proxy() method connects the
widget specified by proxy to the gtk.Action object as
a proxy. This method synchronizes various properties of the gtk.Action with the
widget (such as label text, icon, tooltip, etc), and attaches a callback so
that the gtk.Action is
activated when proxy is.If proxy is already connected to another
gtk.Action, it
is disconnected first. The gtk.Action should be
added to a gtk.ActionGroup
before calling this method.gtk.Action.disconnect_proxydisconnect_proxyproxyproxy :the proxy widgetThis method is available in PyGTK 2.4 and above.The disconnect_proxy() method
disconnects the widget specified by proxy from the
gtk.Action. This
method does not destroy the widget. The gtk.Action should be
added to a gtk.ActionGroup
before calling this method.gtk.Action.get_proxiesget_proxiesReturns :a list of proxy widgets.This method is available in PyGTK 2.4 and above.The get_proxies() method returns a list
containing the proxy widgets associated with the gtk.Action.gtk.Action.connect_acceleratorconnect_acceleratorThis method is available in PyGTK 2.4 and above.The connect_accelerator() method
installs the accelerator for the gtk.Action if it has
an associated accel path and gtk.AccelGroup. See
the set_accel_path()
and the set_accel_group()
methods.Since multiple proxies may independently trigger the
installation of the accelerator, the gtk.Action counts
the number of times this method has been called and doesn't remove the
accelerator until disconnect_accelerator()
has been called as many times.gtk.Action.disconnect_acceleratordisconnect_acceleratorThis method is available in PyGTK 2.4 and above.The disconnect_accelerator() method
undoes the effect of one call to the connect_accelerator()
method.gtk.Action.block_activate_fromblock_activate_fromproxyproxy :a proxy widgetThis method is available in PyGTK 2.4 and above.The block_activate_from() method
disables calls to the activate()
method by signals on the widget specified by
proxy. This is used to break notification loops for
things like check or radio actions.This method is intended for use by gtk.Action
implementations.gtk.Action.unblock_activate_fromunblock_activate_fromproxyproxy :a proxy widgetThis method is available in PyGTK 2.4 and above.The unblock_activate_from() method
re-enables calls to the activate()
method by signals on the widget specified by proxy.
This undoes the blocking done by the block_activate_from()
method.This method is intended for use by gtk.Action
implementations.gtk.Action.get_accel_pathget_accel_pathReturns :the accelerator path associated with the action
or NoneThis method is available in PyGTK 2.6 and above.The get_accel_path() method returns the
accel path for the action or None if no accel path is
set.gtk.Action.set_accel_pathset_accel_pathaccel_pathaccel_path :the accelerator pathThis method is available in PyGTK 2.4 and above.The set_accel_path() method sets the
accel path for the action to the value of
accel_path. All proxy widgets associated with the
action will have this accel path, so that their accelerators are
consistent.gtk.Action.get_always_show_imageget_always_show_imageReturns :Returns True if the action's menu item proxies always show their image, False otherwiseThis method is available in PyGTK 2.22 and above.The get_always_show_image() method returns whether the action's
menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available.gtk.Action.set_always_show_imageset_always_show_imagealways_showalways_show :If True the action's menu item proxies will always show their imageThis method is available in PyGTK 2.22 and above.The set_always_show_image() method sets whether the action's
menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available.
Use this if the menu item would be useless or hard to use without their image.gtk.Action.set_accel_groupset_accel_groupaccel_groupaccel_group :a gtk.AccelGroup or NoneThis method is available in PyGTK 2.4 and above.The set_accel_group() method sets the
gtk.AccelGroup
specified by accel_group as the accelerator group for
the gtk.Action.gtk.Action.set_giconset_giconiconicon :the gio.Icon to set .
This method is available in PyGTK 2.16 and above.
The set_gicon() method sets the icon of action.
gtk.Action.set_icon_nameset_icon_nameicon_nameicon_name :the icon name to set.
This method is available in PyGTK 2.16 and above.
The set_icon_name() method sets the icon name on action.
gtk.Action.set_is_importantset_is_importantis_importantis_important :True to make the action important
This method is available in PyGTK 2.16 and above.
The set_is_important() method sets whether the action is important,
this attribute is used primarily by toolbar items to decide whether to show a label or not.
gtk.Action.set_labelset_labellabellabel :the label text to set.
This method is available in PyGTK 2.16 and above.
The set_is_important() method sets the label of action.
gtk.Action.set_short_labelset_short_labelshort_labelshort_label :the short label text to set.
This method is available in PyGTK 2.16 and above.
The set_short_label() method sets the short label of action.
gtk.Action.set_sensitiveset_sensitivesensitivesensitive :if True make the action
sensitiveThis method is available in PyGTK 2.6 and above.The set_sensitive() method sets the
"sensitive" property to the value of sensitive. Note
that this doesn't necessarily set the effective sensitivity. See the is_sensitive()
method for more information.gtk.Action.set_stock_idset_stock_idstock_idstock_id :the stock id.
This method is available in PyGTK 2.16 and above.
The set_stock_id() method sets the stock id on action
gtk.Action.set_tooltipset_tooltiptooltiptooltip :the tooltip text.
This method is available in PyGTK 2.16 and above.
The set_tooltip() method sets the tooltip text on action.
gtk.Action.set_visibleset_visiblevisiblevisible :if True make the action
visibleThis method is available in PyGTK 2.6 and above.The set_visible() method sets the
"visible" property to the value of visible. Note that
this doesn't necessarily set the effective visibility. See the is_visible()
method for more information.gtk.Action.set_visible_horizontalset_visible_horizontalvisible_horizontalvisible_horizontal :whether the action is visible horizontally.
This method is available in PyGTK 2.16 and above.
The set_visible_horizontal() method sets whether action
is visible when horizontal
gtk.Action.set_visible_verticalset_visible_verticalvisible_verticalvisible_vertical :whether the action is visible vertically.
This method is available in PyGTK 2.16 and above.
The set_visible_vertical() method sets whether action
is visible when vertical
gtk.Action.set_menu_item_typeset_menu_item_typevisibletype :the type of menuitem to be created for the
actionThis method is available in PyGTK 2.10 and above.The set_menu_item_type() method is a
classmethod that sets the type of menuitem to be created for the
action to that specified by type. This is
useful when using the gtk.UIManager
and you would like to use something other than a gtk.ImageMenuItem
(gtk.Action) or
a gtk.CheckMenuItem
(gtk.ToogleAction
or gtk.RadioAction).gtk.Action.set_tool_item_typeset_tool_item_typevisibletype :the type of toolitem to be created for the
actionThis method is available in PyGTK 2.10 and above.The set_tool_item_type() method is a
classmethod that sets the type of toolitem to be created for the
action to that specified by type. This is
useful when using the gtk.UIManager
and you would like to use something other than a gtk.ToolButton
(gtk.Action) or
a gtk.ToggleToolButton
(gtk.ToogleAction
or gtk.RadioAction).For example, to use a gtk.MenuToolButton
in a toolbar you would subclass gtk.Action:
class MenuToolAction(gtk.Action):
__gtype_name__ = "MenuToolAction"
gobject.type_register(MenuToolAction)
and then call set_tool_item_type():
MenuToolAction.set_tool_item_type(gtk.MenuToolButton)
You have to create, name and add an instance of
MenuToolAction to your gtk.ActionGroup:
actiongroup.add_action(MenuToolAction("my_menutoolaction", "_MTB_label",
"do something", None))
The ui description should reference the
MenuToolAction like:
<toolitem action="my_menutoolaction"/>
After the gtk.UIManager
creates the toolbar including the gtk.MenuToolButton
proxy for the MenuToolAction, you would have to
create and add a menu to the gtk.MenuToolButton
instance.This technique can be extended by subclassing gtk.ToolItem
and adding custom widgets to it.gtk.Action.unblock_activateunblock_activateThis method is available in PyGTK 2.16 and above.
The unblock_activate() method reenables activation
signals from the action.
SignalsThe "activate" gtk.Action Signalcallbackactionuser_param1...action :the gtk.Action that
received the signaluser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)This signal is available in PyGTK 2.4 and above.The "activate" signal is emitted when
action is activated.