wx.lib.agw.shortcuteditor.ListShortcut¶
ListShortcut
is a subclass of HyperTreeList
,
customized to look like the GIMP main shortcut list. This class is used to display the
shortcut label (with an optional bitmap next to it), its accelerator and
the help string associated with it (if present).
This information is displayed in 3 columns inside ListShortcut
.
Class Hierarchy¶
Known Superclasses¶
wx.lib.agw.hypertreelist.HyperTreeList
, wx.lib.mixins.treemixin.ExpansionState
Methods Summary¶
Default class constructor. |
|
Returns |
|
Recursively builds the |
|
Calculates an offset (in pixels) so that the |
|
If the user decides to reassign a shortcut to another item, this method will disable |
|
Fires the |
|
Fires the |
|
Return a hashable object that represents the identity of a |
|
Overridden from |
|
Builds the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Recursively populates the |
|
Recreates the entire |
|
Sets the filter string against all the shortcuts in the |
|
Shows/Hides a |
Class API¶
- class ListShortcut(HTL.HyperTreeList, treemixin.ExpansionState)¶
ListShortcut
is a subclass ofHyperTreeList
, customized to look like the GIMP main shortcut list. This class is used to display the shortcut label (with an optional bitmap next to it), its accelerator and the help string associated with it (if present).This information is displayed in 3 columns inside
ListShortcut
.
Methods¶
- __init__(self, parent)¶
Default class constructor.
- Parameters:
parent – an instance of
ShortcutEditor
.
- AcceptShortcut(self, shortcut, accelerator)¶
Returns
True
if the input accelerator is a valid shortcut,False
otherwise.- Parameters:
shortcut – an instance of
Shortcut
;accelerator (string) – the new accelerator to check.
Note
Conflicting shortcuts are handled inside this method by presenting the user with a conflict dialog. At this point the user can decide to reassign an existing shortcut or to back away, in which case this method will return
False
.
- BuildImageList(self, shortcut=None, index=None)¶
Recursively builds the
ListShortcut
image list based on the bitmaps in theShortcut
hierarchy.- Parameters:
shortcut – an instance of
Shortcut
. IfNone
, it is defaulted to self.manager to make this function reentrant (i.e. allow more than one enumeration on one and the same object simultaneously);index (integer) – the current image index inside the
ListShortcut
ownwx.ImageList
.
- CalculateOffset(self)¶
Calculates an offset (in pixels) so that the
Shortcut
items without a bitmap look parallel to the ones with a bitmap.
- DisableShortcut(self, conflict, item=None)¶
If the user decides to reassign a shortcut to another item, this method will disable the conflicting shortcut (by putting a “Disabled” string as its accelerator).
- Parameters:
conflict – an instance of
Shortcut
to reset;item – an instance of
GenericTreeItem
. If defaulted toNone
, it is set to theListShortcut
root item and used only to make this function reentrant (i.e. allow more than one enumeration on one and the same object simultaneously).
- FireShortcutChanged(self, shortcut, newAccel)¶
Fires the
EVT_SHORTCUT_CHANGED
event forListShortcut
.- Parameters:
shortcut – an instance of
Shortcut
that has been renamed;newAccel (string) – the new accelerator just entered by the user.
- FireShortcutChanging(self, shortcut, newAccel)¶
Fires the
EVT_SHORTCUT_CHANGING
event forListShortcut
.The event propagation (and thus the shortcut renaming by the user) can be interrupted by not calling event.Skip() in your handler for this event.
- Parameters:
shortcut – an instance of
Shortcut
that is about to be renamed;newAccel (string) – the new accelerator just entered by the user.
- GetItemIdentity(self, item)¶
Return a hashable object that represents the identity of a
ListShortcut
item.In this implementation this returns the item label.
- Parameters:
item – an instance of
GenericTreeItem
.
- HasFlag(self, flag)¶
Overridden from
wx.Window
as a workaround on the conflicts betweentreemixin
andHyperTreeList
with thewx.TR_HIDE_ROOT
agwStyle set.- Parameters:
flag (integer) – an integer bit flag specifying the agwStyle style.
- Returns:
True
if theListShortcut
has the input flag set,False
otherwise.
Note
Overridden from
wx.Window
.
- MakeImageList(self)¶
Builds the
ListShortcut
image list based on the bitmaps in theShortcut
hierarchy.
- OnExpandCollapse(self, event)¶
Handles the
wx.EVT_TREE_ITEM_COLLAPSED
/wx.EVT_TREE_ITEM_EXPANDED
events forListShortcut
.- Parameters:
event – an instance of
TreeEvent
.
- OnKillFocus(self, event)¶
Handles the
wx.EVT_KILL_FOCUS
event forListShortcut
.- Parameters:
event – an instance of
FocusEvent
.
- OnLeftDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWN
event forListShortcut
.- Parameters:
event – an instance of
MouseEvent
.
- OnSelChanged(self, event)¶
Handles the
wx.EVT_TREE_SEL_CHANGED
event forListShortcut
.- Parameters:
event – an instance of
TreeEvent
.
- OnShortcut(self, event)¶
Handles the
wx.EVT_CHAR_HOOK
event forShortcutEditor
, implemented inListShortcut
as it is easier to deal with in this class.- Parameters:
event – an instance of
KeyEvent
.
- Populate(self, item=None, shortcut=None)¶
Recursively populates the
ListShortcut
with information from theShortcut
tree.- Parameters:
item – an instance of
GenericTreeItem
. IfNone
, it is defaulted to theListShortcut
root item to make this function reentrant (i.e. allow more than one enumeration on one and the same object simultaneously);shortcut – an instance of
Shortcut
. IfNone
, it is defaulted to self.manager to make this function reentrant (i.e. allow more than one enumeration on one and the same object simultaneously).
- RecreateTree(self)¶
Recreates the entire
ListShortcut
(columns excluded).
- SetFilter(self, filter='')¶
Sets the filter string against all the shortcuts in the
ListShortcut
are matched.- Parameters:
filter (string) – a string to match.
- ShowShortcutText(self, show)¶
Shows/Hides a
TextCtrl
used to display the combination of keystrokes the user has entered. ThisTextCtrl
remains visible only for a short amount of time and only when some keys are down.- Parameters:
show (bool) –
True
to show theTextCtrl
,False
to hide it.