AGW Logo

agw_title 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.

hierarchy Inheritance Diagram

Inheritance diagram for: ListShortcut

Inheritance diagram of ListShortcut


supclasses Known Superclasses


method_summary Methods Summary

__init__Default class constructor.
AcceptShortcutReturns True if the input accelerator is a valid shortcut, False otherwise.
BuildImageListRecursively builds the ListShortcut image list based on the bitmaps in the
CalculateOffsetCalculates an offset (in pixels) so that the Shortcut items without
DisableShortcutIf the user decides to reassign a shortcut to another item, this method will disable
FireShortcutChangedFires the EVT_SHORTCUT_CHANGED event for ListShortcut.
FireShortcutChangingFires the EVT_SHORTCUT_CHANGING event for ListShortcut.
GetItemIdentityReturn a hashable object that represents the identity of a ListShortcut item.
HasFlagOverridden from wx.Window as a workaround on the conflicts between treemixin and
MakeImageListBuilds the ListShortcut image list based on the bitmaps in the Shortcut hierarchy.
OnExpandCollapseHandles the wx.EVT_TREE_ITEM_COLLAPSED / wx.EVT_TREE_ITEM_EXPANDED events for ListShortcut.
OnKillFocusHandles the wx.EVT_KILL_FOCUS event for ListShortcut.
OnLeftDownHandles the wx.EVT_LEFT_DOWN event for ListShortcut.
OnSelChangedHandles the wx.EVT_TREE_SEL_CHANGED event for ListShortcut.
OnShortcutHandles the wx.EVT_CHAR_HOOK event for ShortcutEditor, implemented in ListShortcut
PopulateRecursively populates the ListShortcut with information from the Shortcut tree.
RecreateTreeRecreates the entire ListShortcut (columns excluded).
SetFilterSets the filter string against all the shortcuts in the ListShortcut are matched.
ShowShortcutTextShows/Hides a wx.TextCtrl used to display the combination of keystrokes the user

API Class API

class ListShortcut(HTL.HyperTreeList, treemixin.ExpansionState)[source]

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.



__init__(parent)[source]

Default class constructor.

Parameters:parent – an instance of ShortcutEditor.


AcceptShortcut(shortcut, accelerator)[source]

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(shortcut=None, index=None)[source]

Recursively builds the ListShortcut image list based on the bitmaps in the Shortcut hierarchy.

Parameters:
  • shortcut – an instance of Shortcut. If None, 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 own wx.ImageList.


CalculateOffset()[source]

Calculates an offset (in pixels) so that the Shortcut items without a bitmap look parallel to the ones with a bitmap.



DisableShortcut(conflict, item=None)[source]

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 to None, it is set to the ListShortcut 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(shortcut, newAccel)[source]

Fires the EVT_SHORTCUT_CHANGED event for ListShortcut.

Parameters:
  • shortcut – an instance of Shortcut that has been renamed;
  • newAccel (string) – the new accelerator just entered by the user.


FireShortcutChanging(shortcut, newAccel)[source]

Fires the EVT_SHORTCUT_CHANGING event for ListShortcut.

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(item)[source]

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(flag)[source]

Overridden from wx.Window as a workaround on the conflicts between treemixin and HyperTreeList with the wx.TR_HIDE_ROOT agwStyle set.

Parameters:flag (integer) – an integer bit flag specifying the agwStyle style.
Returns:True if the ListShortcut has the input flag set, False otherwise.

Note

Overridden from wx.Window.



MakeImageList()[source]

Builds the ListShortcut image list based on the bitmaps in the Shortcut hierarchy.



OnExpandCollapse(event)[source]

Handles the wx.EVT_TREE_ITEM_COLLAPSED / wx.EVT_TREE_ITEM_EXPANDED events for ListShortcut.

Parameters:event – an instance of wx.TreeEvent.


OnKillFocus(event)[source]

Handles the wx.EVT_KILL_FOCUS event for ListShortcut.

Parameters:event – an instance of wx.FocusEvent.


OnLeftDown(event)[source]

Handles the wx.EVT_LEFT_DOWN event for ListShortcut.

Parameters:event – an instance of wx.MouseEvent.


OnSelChanged(event)[source]

Handles the wx.EVT_TREE_SEL_CHANGED event for ListShortcut.

Parameters:event – an instance of wx.TreeEvent.



OnShortcut(event)[source]

Handles the wx.EVT_CHAR_HOOK event for ShortcutEditor, implemented in ListShortcut as it is easier to deal with in this class.

Parameters:event – an instance of wx.KeyEvent.


Populate(item=None, shortcut=None)[source]

Recursively populates the ListShortcut with information from the Shortcut tree.

Parameters:
  • item – an instance of GenericTreeItem. If None, it is defaulted to the ListShortcut 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. If None, 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()[source]

Recreates the entire ListShortcut (columns excluded).



SetFilter(filter=u'')[source]

Sets the filter string against all the shortcuts in the ListShortcut are matched.

Parameters:filter (string) – a string to match.


ShowShortcutText(show)[source]

Shows/Hides a wx.TextCtrl used to display the combination of keystrokes the user has entered. This wx.TextCtrl remains visible only for a short amount of time and only when some keys are down.

Parameters:show (bool) – True to show the wx.TextCtrl, False to hide it.

Tree

Table Of Contents

Previous topic

HTMLHelpWindow

Next topic

Shortcut