Shortcut
is a class containing the details for a shortcut, whether from
a menu item, an accelerator or a user-defined shortcut. It behaves like
a tree, with children and parents.
__init__ |
Default class constructor. |
AppendItem |
Appends a Shortcut item as a last child of its parent. |
CheckAccelerator |
Checks if a shortcut string entered by the user has already been taken by another entry |
FromMenuItem |
Constructs this Shortcut starting from a wx.Menu or wx.MenuItem . |
Get |
Returns an instance of Shortcut whose label matches the input label string. |
GetAccelerator |
Returns the string accelerator associated with this shortcut. |
GetBitmap |
Returns the bitmap associated with this Shortcut . |
GetById |
Returns an instance of Shortcut whose ID matches the input id. |
GetFirstChild |
Returns this Shortcut ‘s first child and an integer value ‘cookie’. |
GetId |
Returns this Shortcut ID. |
GetImageIndex |
Returns an integer index to be used in the ListShortcut own wx.ImageList . |
GetLabel |
Returns the string label associated with this shortcut. |
GetNextChild |
Returns this Shortcut ‘s next child. |
HasChanged |
Returns True if the current accelerator associated with this Shortcut is |
IsTop |
Returns True if this Shortcut is associated with a top-level wx.Menu , |
Match |
Matches this Shortcut label string against the filter input variable. |
ResetVisibility |
Set the status of this Shortcut and its parent as hidden in the |
RestoreDefaults |
Restore the original shortcut string for this Shortcut . |
SetAccelerator |
Sets the string accelerator associated with this shortcut. |
SetBitmap |
Sets the bitmap associated with this Shortcut . |
ShowHierarchy |
Set the status of this Shortcut ans its parent as shown in the |
ToAcceleratorItem |
Dumps this Shortcut into a tuple of 3 elements |
ToMenuItem |
Dumps this Shortcut into a wx.Menu or wx.MenuItem . |
Shortcut
(object)¶Shortcut
is a class containing the details for a shortcut, whether from
a menu item, an accelerator or a user-defined shortcut. It behaves like
a tree, with children and parents.
__init__
(self, label='', accelerator='', bitmap=wx.NullBitmap, help='', menuItem=None, accelId=None)¶Default class constructor.
Parameters: |
|
---|
AppendItem
(self, item)¶Appends a Shortcut
item as a last child of its parent.
Parameters: | item – an instance of Shortcut . |
---|
CheckAccelerator
(self, item, shortcut, accelerator)¶Checks if a shortcut string entered by the user has already been taken by another entry
in the Shortcut
hierarchy.
Parameters: | |
---|---|
Returns: | An instance of |
FromMenuItem
(self)¶Constructs this Shortcut
starting from a wx.Menu
or wx.MenuItem
.
The attributes needed to properly construct a Shortcut
are the label,
the accelerator string, the help string (optional) and the bitmap associated
with it (optional).
Get
(self, label, item=None)¶Returns an instance of Shortcut
whose label matches the input label string.
Parameters: | |
---|---|
Returns: | An instance of |
GetAccelerator
(self)¶Returns the string accelerator associated with this shortcut.
GetBitmap
(self)¶Returns the bitmap associated with this Shortcut
.
Note
You should always check if the returned bitmap is a valid one or not:
bitmap = shortcut.GetBitmap()
if bitmap.IsOk():
DoSomething()
as the default bitmap associated with a Shortcut
is NullBitmap
.
GetById
(self, id, item=None)¶Returns an instance of Shortcut
whose ID matches the input id.
Parameters: | |
---|---|
Returns: | An instance of |
GetFirstChild
(self, item)¶Returns this Shortcut
‘s first child and an integer value ‘cookie’.
Call GetNextChild
for the next child using this very ‘cookie’ return
value as an input.
Parameters: | item – an instance of Shortcut . |
---|---|
Returns: | A tuple with the first value being an instance of Shortcut or None if there are no
further children, and as second value an integer parameter ‘cookie’. |
Note
This method returns None
if there are no further children.
GetImageIndex
(self)¶Returns an integer index to be used in the ListShortcut
own wx.ImageList
.
GetLabel
(self)¶Returns the string label associated with this shortcut.
GetNextChild
(self, item, cookie)¶Returns this Shortcut
‘s next child.
Parameters: |
|
---|---|
Returns: | A tuple with the first value being an instance of |
Note
This method returns None
if there are no further children.
HasChanged
(self)¶Returns True
if the current accelerator associated with this Shortcut
is
different from the original one, False
otherwise.
IsTop
(self)¶Returns True
if this Shortcut
is associated with a top-level wx.Menu
,
(i.e., in the top wx.MenuBar
level), False
otherwise.
Match
(self, filter='', item=None)¶Matches this Shortcut
label string against the filter input variable.
Parameters: |
|
---|---|
Returns: | An instance of |
Note
The string-matching is case-insensitive.
ResetVisibility
(self, item=None)¶Set the status of this Shortcut
and its parent as hidden in the
ListShortcut
tree hierarchy.
Parameters: | item – an instance of Shortcut , used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously). |
---|
RestoreDefaults
(self, item=None)¶Restore the original shortcut string for this Shortcut
.
Parameters: | item – an instance of Shortcut , used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously). |
---|
SetAccelerator
(self, accelerator)¶Sets the string accelerator associated with this shortcut.
Parameters: | accelerator (string) – a string representing the shortcut string (accelerator). |
---|
SetBitmap
(self, bitmap)¶Sets the bitmap associated with this Shortcut
.
Parameters: | bitmap – an instance of wx.Bitmap (can be invalid, i.e., NullBitmap ). |
---|
ShowHierarchy
(self, item)¶Set the status of this Shortcut
ans its parent as shown in the
ListShortcut
tree hierarchy.
Parameters: | item – an instance of Shortcut . |
---|
ToAcceleratorItem
(self, table)¶Dumps this Shortcut
into a tuple of 3 elements:
wx.ACCEL_ALT
, wx.ACCEL_SHIFT
, wx.ACCEL_CTRL
, wx.ACCEL_CMD
or wx.ACCEL_NORMAL
used to specify which modifier keys are held down;Parameters: | table – a list of tuples, with the above specifications. |
---|
ToMenuItem
(self, menuBar)¶Dumps this Shortcut
into a wx.Menu
or wx.MenuItem
.
The attributes needed to properly dump a Shortcut
into a wx.Menu
or wx.MenuBar
are the label and the accelerator string.
Parameters: | menuBar – an instance of wx.MenuBar . |
---|