1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.lib.agw.shortcuteditor
.. highlight:: python
.. _wx.lib.agw.shortcuteditor.ShortcutEditor:
==========================================================================================================================================
|phoenix_title| **wx.lib.agw.shortcuteditor.ShortcutEditor**
==========================================================================================================================================
:class:`ShortcutEditor` is a widget that allows the user to customize and change keyboard
shortcuts via a dialog. It can be used to edit :class:`wx.MenuItem` shortcuts or accelerators
defined in a :class:`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 :class:`ShortcutEditor` and the GIMP one,
although the behaviour should be pretty much equivalent.
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>ShortcutEditor</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.lib.agw.shortcuteditor.ShortcutEditor_inheritance.png" alt="Inheritance diagram of ShortcutEditor" usemap="#dummy" class="inheritance"/></center>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.agw.shortcuteditor.ShortcutEditor.html" title="wx.lib.agw.shortcuteditor.ShortcutEditor" alt="" coords="5,547,287,576"/> <area shape="rect" id="node2" href="wx.Dialog.html" title="wx.Dialog" alt="" coords="103,469,189,499"/> <area shape="rect" id="node3" href="wx.TopLevelWindow.html" title="wx.TopLevelWindow" alt="" coords="69,392,223,421"/> <area shape="rect" id="node4" href="wx.NonOwnedWindow.html" title="wx.NonOwnedWindow" alt="" coords="62,315,230,344"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="97,237,195,267"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="81,160,211,189"/> <area shape="rect" id="node7" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="87,83,205,112"/> <area shape="rect" id="node8" href="wx.Object.html" title="wx.Object" alt="" coords="43,5,129,35"/> <area shape="rect" id="node9" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="154,5,261,35"/> </map>
</p>
</div>
|
|appearance| Control Appearance
===============================
|
.. figure:: _static/images/widgets/fullsize/wxmsw/wx.lib.agw.shortcuteditor.shortcuteditor.png
:alt: wxMSW
:figclass: floatleft
**wxMSW**
.. figure:: _static/images/widgets/fullsize/wxmac/../no_appearance.png
:alt: wxMAC
:figclass: floatright
**wxMAC**
.. figure:: _static/images/widgets/fullsize/wxgtk/wx.lib.agw.shortcuteditor.shortcuteditor.png
:alt: wxGTK
:figclass: floatcenter
**wxGTK**
|
|super_classes| Known Superclasses
==================================
:class:`wx.Dialog`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.__init__` Default class constructor.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.BindEvents` Binds a few events we will need to process
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.CreateWidgets` Creates all the widgets needed to populate the interface, such as buttons,
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.DoLayout` Lays out the widgets using sizers in a platform-independent way.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.FromAcceleratorTable` Builds the entire shortcut hierarchy starting from a modified version of a :class:`AcceleratorTable`.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.FromMenuBar` Builds the entire shortcut hierarchy starting from a :class:`wx.MenuBar`.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.GetShortcutManager` Returns the root :class:`Shortcut` containing the whole shortcut hierarchy.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.Init` Common initialization procedures.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.OnClearFilter` Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user clears the
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.OnHTMLHelp` Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user presses the ``Help``
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.OnRestoreDefaults` Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user restores the
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.OnSetFilter` Handles the ``wx.EVT_TEXT`` event for :class:`ShortcutEditor`.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.PreShow` Does some more common initialization before showing :class:`ShortcutEditor`.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.SetColumnWidths` Sets the :class:`ListShortcut` columns widths to acceptable and eye-pleasing
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.SetHTMLHelpFile` Sets a new HTML help file (a valid html file) to be loaded when the user seeks
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.Show` Hides or shows the :class:`ShortcutEditor` dialog.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.ShowModal` Shows the :class:`ShortcutEditor` dialog in an application-modal way.
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.ToAcceleratorTable` Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`AcceleratorTable`), into
:meth:`~wx.lib.agw.shortcuteditor.ShortcutEditor.ToMenuBar` Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`wx.MenuItem`), into
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: ShortcutEditor(wx.Dialog)
:class:`ShortcutEditor` is a widget that allows the user to customize and change keyboard
shortcuts via a dialog. It can be used to edit :class:`wx.MenuItem` shortcuts or accelerators
defined in a :class:`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 :class:`ShortcutEditor` and the GIMP one,
although the behaviour should be pretty much equivalent.
.. method:: __init__(self, parent)
Default class constructor.
:param `parent`: an instance of :class:`wx.Window`, it can also be ``None``.
.. method:: BindEvents(self)
Binds a few events we will need to process:
* ``wx.EVT_TEXT`` for the label filtering;
* ``wx.EVT_BUTTON`` for clearing the filtering, for the HTML help window and
to reset all the shortcuts to their defaults.
.. method:: CreateWidgets(self)
Creates all the widgets needed to populate the interface, such as buttons,
texts and, most importantly, :class:`ListShortcut`.
.. method:: DoLayout(self)
Lays out the widgets using sizers in a platform-independent way.
.. method:: FromAcceleratorTable(self, accelTable)
Builds the entire shortcut hierarchy starting from a modified version of a :class:`AcceleratorTable`.
:param `accelTable`: a modified version of :class:`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)
.. method:: FromMenuBar(self, topWindow)
Builds the entire shortcut hierarchy starting from a :class:`wx.MenuBar`.
:param `topWindow`: an instance of :class:`TopLevelWindow`, containing the :class:`wx.MenuBar`
we wish to scan.
.. method:: GetShortcutManager(self)
Returns the root :class:`Shortcut` containing the whole shortcut hierarchy.
.. method:: Init(self)
Common initialization procedures.
.. method:: OnClearFilter(self, event)
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user clears the
label filter at the top of the user interface.
:param `event`: an instance of :class:`CommandEvent`.
.. method:: OnHTMLHelp(self, event)
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user presses the ``Help``
button.
:param `event`: an instance of :class:`CommandEvent`.
.. note::
By default, this method launches a :class:`html.HtmlWindow` containing the default
HTML help file. If you wish to load another help file, you should call :meth:`~ShortcutEditor.SetHTMLHelpFile`
with another input HTML file.
.. method:: OnRestoreDefaults(self, event)
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user restores the
original shortcuts.
:param `event`: an instance of :class:`CommandEvent`.
.. method:: OnSetFilter(self, event=None)
Handles the ``wx.EVT_TEXT`` event for :class:`ShortcutEditor`.
:param `event`: if not ``None``, an instance of :class:`KeyEvent`.
.. method:: PreShow(self)
Does some more common initialization before showing :class:`ShortcutEditor`.
.. method:: SetColumnWidths(self)
Sets the :class:`ListShortcut` columns widths to acceptable and eye-pleasing
numbers (in pixels).
.. method:: SetHTMLHelpFile(self, htmlFile)
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.
:param string `htmlFile`: a valid HTML file.
.. method:: Show(self, show=True)
Hides or shows the :class:`ShortcutEditor` dialog.
The preferred way of dismissing a modal dialog is to use `EndModal`.
:param bool `show`: 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 :class:`wx.Window`.
.. method:: ShowModal(self)
Shows the :class:`ShortcutEditor` dialog in an application-modal way.
Program flow does not return until the dialog has been dismissed with `EndModal`.
:return: The value set with :meth:`~Dialog.SetReturnCode`.
.. note::
Notice that it is possible to call :meth:`~ShortcutEditor.ShowModal` for a dialog which had been
previously shown with :meth:`~ShortcutEditor.Show`, this allows to make an existing modeless dialog
modal. However :meth:`~ShortcutEditor.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 :class:`EventLoopBase`) and which is
destroyed when the dialog is dismissed. This also results in a call to
:meth:`AppConsole.ProcessPendingEvents` ().
.. method:: ToAcceleratorTable(self, window)
Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`AcceleratorTable`), into
a :class:`AcceleratorTable`. This method **does** rebuild the :class:`AcceleratorTable` and sets it back
to the input `window`.
:param `window`: an instance of :class:`wx.Window`, to which the new :class:`AcceleratorTable` should be set.
.. method:: ToMenuBar(self, topWindow)
Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`wx.MenuItem`), into
a :class:`wx.MenuBar`, changing only the :class:`wx.Menu` / :class:`wx.MenuItem` labels (it does **not** rebuild
the :class:`wx.MenuBar`).
:param `topWindow`: an instance of :class:`TopLevelWindow`, containing the :class:`wx.MenuBar`
we wish to repopulate.
|