wx.lib.agw.shortcuteditor.Shortcut¶
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.
Class Hierarchy¶
Methods Summary¶
Default class constructor. |
|
Appends a |
|
Checks if a shortcut string entered by the user has already been taken by another entry |
|
Constructs this |
|
Returns an instance of |
|
Returns the string accelerator associated with this shortcut. |
|
Returns the bitmap associated with this |
|
Returns an instance of |
|
Returns this |
|
Returns this |
|
Returns an integer index to be used in the |
|
Returns the string label associated with this shortcut. |
|
Returns this |
|
Returns |
|
Returns |
|
Matches this |
|
Set the status of this |
|
Restore the original shortcut string for this |
|
Sets the string accelerator associated with this shortcut. |
|
Sets the bitmap associated with this |
|
Set the status of this |
|
Dumps this |
|
Dumps this |
Class API¶
- class Shortcut(object)¶
Shortcutis 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.
Methods¶
- __init__(self, label='', accelerator='', bitmap=wx.NullBitmap, help='', menuItem=None, accelId=None)¶
Default class constructor.
- Parameters:
label (string) – the shortcut label string;
accelerator (string) – the shortcut accelerator string;
bitmap – an instance of
wx.Bitmap, to display along the shortcut label in the interface tree;help (string) – the help string for this shortcut, to display in the interface tree;
menuItem – if this
Shortcutis derived from awx.MenuItem, thewx.MenuItemto which it should be associated;accelId (integer) – if this
Shortcutis derived from an accelerator in aAcceleratorTableor from a custom, developer-defined shortcut, it represents the ID it is associated with.
- AppendItem(self, item)¶
Appends a
Shortcutitem 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
Shortcuthierarchy.- Parameters:
- Returns:
An instance of
Shortcutif the shortcut string entered by the user conflicts with an existing one,Noneotherwise.
- FromMenuItem(self)¶
Constructs this
Shortcutstarting from awx.Menuorwx.MenuItem.The attributes needed to properly construct a
Shortcutare 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
Shortcutwhose label matches the input label string.- Parameters:
- Returns:
An instance of
ShortcutorNoneif no match was found.
- 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
ShortcutisNullBitmap.
- GetFirstChild(self, item)¶
Returns this
Shortcut’s first child and an integer value ‘cookie’. CallGetNextChildfor 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
ShortcutorNoneif there are no further children, and as second value an integer parameter ‘cookie’.
Note
This method returns
Noneif there are no further children.
- GetImageIndex(self)¶
Returns an integer index to be used in the
ListShortcutownwx.ImageList.
- GetLabel(self)¶
Returns the string label associated with this shortcut.
- GetNextChild(self, item, cookie)¶
Returns this
Shortcut’s next child.- Parameters:
item – an instance of
Shortcut;cookie (integer) – a parameter which is opaque for the application but is necessary for the library to make this function reentrant (i.e. allow more than one enumeration on one and the same object simultaneously).
- Returns:
A tuple with the first value being an instance of
ShortcutorNoneif there are no further children, and as second value an integer parameter ‘cookie’.
Note
This method returns
Noneif there are no further children.
- HasChanged(self)¶
Returns
Trueif the current accelerator associated with thisShortcutis different from the original one,Falseotherwise.
- IsTop(self)¶
Returns
Trueif thisShortcutis associated with a top-levelwx.Menu, (i.e., in the topwx.MenuBarlevel),Falseotherwise.
- Match(self, filter='', item=None)¶
Matches this
Shortcutlabel string against the filter input variable.- Parameters:
filter (string) – a string to match;
item – an instance of
Shortcut: its label string is compared with the filter string to look for a match.
- Returns:
An instance of
Shortcutif the filter string is contained in the item label,Noneotherwise.
Note
The string-matching is case-insensitive.
- ResetVisibility(self, item=None)¶
Set the status of this
Shortcutand its parent as hidden in theListShortcuttree 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
Shortcutans its parent as shown in theListShortcuttree hierarchy.- Parameters:
item – an instance of
Shortcut.
- ToAcceleratorItem(self, table)¶
Dumps this
Shortcutinto a tuple of 3 elements:flags: a bitmask of
wx.ACCEL_ALT,wx.ACCEL_SHIFT,wx.ACCEL_CTRL,wx.ACCEL_CMDorwx.ACCEL_NORMALused to specify which modifier keys are held down;keyCode: the keycode to be detected (i.e., ord(‘b’), wx.WXK_F10, etc…);
cmdID: the menu or control command ID to use for the accelerator event.
- Parameters:
table – a list of tuples, with the above specifications.
- ToMenuItem(self, menuBar)¶
Dumps this
Shortcutinto awx.Menuorwx.MenuItem.The attributes needed to properly dump a
Shortcutinto awx.Menuorwx.MenuBarare the label and the accelerator string.- Parameters:
menuBar – an instance of
wx.MenuBar.