|
class gtk.ItemFactory(gtk.Object): |
Functionsdef gtk.item_factory_from_widget(
widget
)def gtk.item_factory_path_from_widget(
widget
)
gtk.ItemFactory
is deprecated in PyGTK 2.4 and above. The gtk.UIManager
should be used instead.
The gtk.ItemFactory
provides a convenient way to create and manage menus, menubars and option
menus from a data description. The data description is a tuple or list
containing a list of entry tuples that each describe an individual menu,
menuitem, etc. Each entry tuple may contain the following entry fields
though only the path must be specified; the other fields are
optional:
An accelerator that defines a key sequence that will activate the menuitem. The key sequence is a set of zero or more modifiers followed by a single key. The modifier keys are:
"<alt>" | Alt-Lor Alt-R |
"<ctl>", "<ctrl>", "<control>" | Ctrl-Lor Ctrl-R |
"<shift>", "<shft>" | Shift-Lor Shift-R |
A callback function or method that will be invoked when the menu item is activated or the accelerator key sequence is pressed. The callback function is defined as either:
def callback(callback_data, callback_action, widget) def callback(callback_action, widget)
where callback_action
is the
callback action defined below, callback_data
is the
data passed with the create_items
()
method and widget
is the menuitem widget. The second
definition must be used if no callback_data
argument
is specified by the call to create_items
().
An item type is a string describing the type of the item:
"None", "", "Item" | a simple menu item |
"<Title>" | a title item |
"<ImageItem>" | an image item |
"<StockItem>" | an item holding a stock image |
"<CheckItem>" | a check item |
"<ToggleItem>" | a toggle item |
"<RadioItem>" | a radio item |
<path> | the path of a radio item group to add item to |
"<Separator>" | a separator |
"<Tearoff>" | a tearoff separator |
"<Branch>" | an item to hold sub items |
"<LastBranch>" | a right justified item to hold sub items |
gtk.gdk.Pixbuf
or a
stock ID gtk.ItemFactory(container_type
, path
, accel_group
=None)
| the kind of menu to create; one of: gtk.MenuBar , gtk.Menu or gtk.OptionMenu . |
| the path of the new item factory, a string of the
form "<name>" |
| a gtk.AccelGroup
to which the accelerators for the menu items will be added, or
None to create a new one |
Returns : | a new gtk.ItemFactory |
Creates a new gtk.ItemFactory
object.
def construct(container_type
, path
, accel_group
)
| the kind of menu to create; one of: gtk.MenuBar , gtk.Menu or gtk.OptionMenu . |
| the path of the item factory, a string of the
form "<name>" |
| a gtk.AccelGroup
to which the accelerators for the menu items will be added, or
None to create a new one |
The construct
() method initializes an
item factory.
def get_item(path
)
| the path to the menu item |
Returns : | the menu item with the specified
path , or None if
path doesn't lead to a menu item |
The get_item
() method returns the menu
item that corresponds to path
. If the widget
corresponding to path
is a menu item that opens a
submenu, then the item is returned. If you are interested in the submenu,
use the get_widget
()
method instead.
def get_widget(path
)
| the path to the widget |
Returns : | the widget associated with the specified
path , or None if
path doesn't lead to a widget |
The get_widget
() method returns the
widget that corresponds to path
. If the widget
corresponding to path
is a menu item that opens a
submenu, then the submenu is returned. If you are interested in the menu
item, use get_item
()
instead.
def get_widget_by_action(action
)
| a callback action value |
Returns : | the widget that corresponds to the given
action, or None if no widget was
found |
The get_widget_by_action
() method
returns the widget that is associated with the specified
action
. If there are multiple items with the same
action
, the result is undefined.
def get_item_by_action(action
)
| a callback action value |
Returns : | the menu item that corresponds to the specified
action , or None if no menu item
was found |
The get_item_by_action
() returns the
menu item that is associated with the specified
action
.
def create_items(entries
, callback_data
=None)
| a tuple or list of item factory entries |
| optional data passed to the callback functions of all entries |
The create_items
() method creates the
menu items from the specified item factory entries
.
If no callback_data
is specified it will not be
passed to the callback functions i.e the callback functions will be passed
one less argument.
def delete_item(path
)
| a path |
The delete_item
() method deletes the
menu item that was created with the specified
path
.
def popup(x
, y
, mouse_button
, time
=0L)
| the x position |
| the y position |
| the mouse button that was pressed to initiate this action |
| an optional timestamp for this action; default is 0L which means use the current time |
The popup
() method pops up the menu
constructed from the item factory at the specified location
(x
, y
). This method is
generally invoked in response to a "button_press_event" so the arguments are
retrieved from the event information.
def gtk.item_factory_from_widget(widget
)
| a gtk.Widget
object |
Returns : | the gtk.ItemFactory
that created widget |
The gtk.item_factory_from_widget
() function
returns the gtk.ItemFactory
object that created the gtk.Widget
specified
by widget
.
def gtk.item_factory_path_from_widget(widget
)
| a gtk.Widget
object |
Returns : | the full path to the gtk.ItemFactory
that created widget |
The gtk.item_factory_path_from_widget
()
function returns the full path to the gtk.ItemFactory
that created the gtk.Widget
specified
by widget
.
© manpagez.com 2000-2024 Individual documents may contain additional copyright information.