ShortcutEditor is a widget that allows the user to customize and change keyboard shortcuts via a dialog. It can be used to edit wx.MenuItem shortcuts or accelerators defined in a wx.AcceleratorTable.
The interface itself is very much inpired by the GIMP shortcut editor:
http://graphicssoft.about.com/od/gimptutorials/tp/keyboard-shortcut-editor.htm
There are very few minor UI differences between ShortcutEditor and the GIMP one, although the behaviour should be pretty much equivalent.
__init__ | Default class constructor. |
BindEvents | Binds a few events we will need to process: |
CreateWidgets | Creates all the widgets needed to populate the interface, such as buttons, |
DoLayout | Lays out the widgets using sizers in a platform-independent way. |
FromAcceleratorTable | Builds the entire shortcut hierarchy starting from a modified version of a wx.AcceleratorTable. |
FromMenuBar | Builds the entire shortcut hierarchy starting from a wx.MenuBar. |
GetShortcutManager | Returns the root Shortcut containing the whole shortcut hierarchy. |
Init | Common initialization procedures. |
OnClearFilter | Handles the wx.EVT_BUTTON event for ShortcutEditor when the user clears the |
OnHTMLHelp | Handles the wx.EVT_BUTTON event for ShortcutEditor when the user presses the Help |
OnRestoreDefaults | Handles the wx.EVT_BUTTON event for ShortcutEditor when the user restores the |
OnSetFilter | Handles the wx.EVT_TEXT event for ShortcutEditor. |
PreShow | Does some more common initialization before showing ShortcutEditor. |
SetColumnWidths | Sets the ListShortcut columns widths to acceptable and eye-pleasing |
SetHTMLHelpFile | Sets a new HTML help file (a valid html file) to be loaded when the user seeks |
Show | Hides or shows the ShortcutEditor dialog. |
ShowModal | Shows the ShortcutEditor dialog in an application-modal way. |
ToAcceleratorTable | Dumps the entire shortcut hierarchy (for shortcuts associated with a wx.AcceleratorTable), into |
ToMenuBar | Dumps the entire shortcut hierarchy (for shortcuts associated with a wx.MenuItem), into |
ShortcutEditor is a widget that allows the user to customize and change keyboard shortcuts via a dialog. It can be used to edit wx.MenuItem shortcuts or accelerators defined in a wx.AcceleratorTable.
The interface itself is very much inpired by the GIMP shortcut editor:
http://graphicssoft.about.com/od/gimptutorials/tp/keyboard-shortcut-editor.htm
There are very few minor UI differences between ShortcutEditor and the GIMP one, although the behaviour should be pretty much equivalent.
Default class constructor.
Parameters: | parent – an instance of wx.Window, it can also be None. |
---|
Binds a few events we will need to process:
Creates all the widgets needed to populate the interface, such as buttons, texts and, most importantly, ListShortcut.
Builds the entire shortcut hierarchy starting from a modified version of a wx.AcceleratorTable.
Parameters: | accelTable – a modified version of wx.AcceleratorTable, is a list of tuples (4 elements per tuple),
populated like this:
accelTable = []
# Every tuple is defined in this way:
for label, flags, keyCode, cmdID in my_accelerators:
# label: the string used to show the accelerator into the ShortcutEditor dialog
# flags: a bitmask of 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
# 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.
accel_tuple = (label, flags, keyCode, cmdID)
accelTable.append(accel_tuple)
|
---|
Builds the entire shortcut hierarchy starting from a wx.MenuBar.
Parameters: | topWindow – an instance of wx.TopLevelWindow, containing the wx.MenuBar we wish to scan. |
---|
Handles the wx.EVT_BUTTON event for ShortcutEditor when the user clears the label filter at the top of the user interface.
Parameters: | event – an instance of wx.CommandEvent. |
---|
Handles the wx.EVT_BUTTON event for ShortcutEditor when the user presses the Help button.
Parameters: | event – an instance of wx.CommandEvent. |
---|
Note
By default, this method launches a wx.html.HtmlWindow containing the default HTML help file. If you wish to load another help file, you should call SetHTMLHelpFile with another input HTML file.
Handles the wx.EVT_BUTTON event for ShortcutEditor when the user restores the original shortcuts.
Parameters: | event – an instance of wx.CommandEvent. |
---|
Handles the wx.EVT_TEXT event for ShortcutEditor.
Parameters: | event – if not None, an instance of wx.KeyEvent. |
---|
Does some more common initialization before showing ShortcutEditor.
Sets the ListShortcut columns widths to acceptable and eye-pleasing numbers (in pixels).
Sets a new HTML help file (a valid html file) to be loaded when the user seeks for an explanation on how the UI works.
Parameters: | htmlFile (string) – a valid HTML file. |
---|
Hides or shows the ShortcutEditor dialog.
The preferred way of dismissing a modal dialog is to use EndModal.
Parameters: | show (bool) – if True, the dialog box is shown and brought to the front, otherwise the box is hidden. If False and the dialog is modal, control is returned to the calling program. |
---|
Note
Reimplemented from wx.Window.
Shows the ShortcutEditor dialog in an application-modal way.
Program flow does not return until the dialog has been dismissed with EndModal.
Returns: | The value set with SetReturnCode. |
---|
Note
Notice that it is possible to call ShowModal for a dialog which had been previously shown with Show, this allows to make an existing modeless dialog modal. However ShowModal can’t be called twice without intervening EndModal calls.
Note
Note that this function creates a temporary event loop which takes precedence over the application’s main event loop (see wx.EventLoopBase) and which is destroyed when the dialog is dismissed. This also results in a call to wx.App.ProcessPendingEvents().
Dumps the entire shortcut hierarchy (for shortcuts associated with a wx.AcceleratorTable), into a wx.AcceleratorTable. This method does rebuild the wx.AcceleratorTable and sets it back to the input window.
Parameters: | window – an instance of wx.Window, to which the new wx.AcceleratorTable should be set. |
---|
Dumps the entire shortcut hierarchy (for shortcuts associated with a wx.MenuItem), into a wx.MenuBar, changing only the wx.Menu / wx.MenuItem labels (it does not rebuild the wx.MenuBar).
Parameters: | topWindow – an instance of wx.TopLevelWindow, containing the wx.MenuBar we wish to repopulate. |
---|