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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.lib.buttons
.. highlight:: python
.. _wx.lib.buttons.GenButton:
==========================================================================================================================================
|phoenix_title| **wx.lib.buttons.GenButton**
==========================================================================================================================================
A generic button, and base class for the other generic buttons.
|
|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>GenButton</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.buttons.GenButton_inheritance.png" alt="Inheritance diagram of GenButton" 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.buttons.GenButton.html" title="wx.lib.buttons.GenButton" alt="" coords="15,392,202,421"/> <area shape="rect" id="node2" href="wx.Control.html" title="wx.Control" alt="" coords="63,315,155,344"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window" alt="" coords="60,237,157,267"/> <area shape="rect" id="node4" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="44,160,173,189"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node6" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map>
</p>
</div>
|
|sub_classes| Known Subclasses
==============================
:class:`wx.lib.analogclock.lib_setup.fontselect.FontSelect`, :class:`wx.lib.buttons.GenBitmapButton`, :class:`wx.lib.buttons.GenToggleButton`, :class:`wx.lib.buttons.ThemedGenButton`
|
|super_classes| Known Superclasses
==================================
:class:`wx.Control`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.lib.buttons.GenButton.__init__` Default class constructor.
:meth:`~wx.lib.buttons.GenButton.AcceptsFocus` Can this window be given focus by mouse click?
:meth:`~wx.lib.buttons.GenButton.DoGetBestSize` Overridden base class virtual. Determines the best size of the
:meth:`~wx.lib.buttons.GenButton.DrawBezel`
:meth:`~wx.lib.buttons.GenButton.DrawFocusIndicator`
:meth:`~wx.lib.buttons.GenButton.DrawLabel`
:meth:`~wx.lib.buttons.GenButton.Enable` Enables/disables the button.
:meth:`~wx.lib.buttons.GenButton.GetBackgroundBrush` Returns the current :class:`wx.Brush` to be used to draw the button background.
:meth:`~wx.lib.buttons.GenButton.GetBezelWidth` Returns the width of the 3D effect, in pixels.
:meth:`~wx.lib.buttons.GenButton.GetDefaultAttributes` Overridden base class virtual. By default we should use
:meth:`~wx.lib.buttons.GenButton.GetUseFocusIndicator` Returns the focus indicator flag, specifying if a focus indicator
:meth:`~wx.lib.buttons.GenButton.InitColours` Calculate a new set of highlight and shadow colours based on
:meth:`~wx.lib.buttons.GenButton.InitOtherEvents` Override this method in a subclass to initialize any other events that
:meth:`~wx.lib.buttons.GenButton.Notify` Actually sends a ``wx.EVT_BUTTON`` event to the listener (if any).
:meth:`~wx.lib.buttons.GenButton.OnGainFocus` Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnKeyDown` Handles the ``wx.EVT_KEY_DOWN`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnKeyUp` Handles the ``wx.EVT_KEY_UP`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLeftDown` Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLeftUp` Handles the ``wx.EVT_LEFT_UP`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLoseCapture` Handles the ``wx.EVT_MOUSE_CAPTURE_LOST`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLoseFocus` Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnMotion` Handles the ``wx.EVT_MOTION`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnPaint` Handles the ``wx.EVT_PAINT`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnSize` Handles the ``wx.EVT_SIZE`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.SetBackgroundColour` Sets the :class:`GenButton` background colour.
:meth:`~wx.lib.buttons.GenButton.SetBezelWidth` Sets the width of the 3D effect.
:meth:`~wx.lib.buttons.GenButton.SetDefault` This sets the :class:`GenButton` to be the default item for
:meth:`~wx.lib.buttons.GenButton.SetForegroundColour` Sets the :class:`wx.GenButton` foreground colour.
:meth:`~wx.lib.buttons.GenButton.SetInitialSize` Given the current font and bezel width settings, calculate
:meth:`~wx.lib.buttons.GenButton.SetUseFocusIndicator` Specifies if a focus indicator (dotted line) should be used.
:meth:`~wx.lib.buttons.GenButton.ShouldInheritColours` Overridden base class virtual. Buttons usually don't inherit
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: GenButton(wx.Control)
A generic button, and base class for the other generic buttons.
.. method:: __init__(self, parent, id=-1, label='', pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, validator = wx.DefaultValidator, name = "genbutton")
Default class constructor.
:param wx.Window `parent`: parent window. Must not be ``None``;
:param integer `id`: window identifier. A value of -1 indicates a default value;
:param string `label`: the button text label;
:param `pos`: the control position. A value of (-1, -1) indicates a default
position, chosen by either the windowing system or wxPython, depending on
platform;
:type `pos`: tuple or :class:`wx.Point`
:param `size`: the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform;
:type `size`: tuple or :class:`wx.Size`
:param integer `style`: the button style;
:param wx.Validator `validator`: the validator associated with the button;
:param string `name`: the button name.
.. seealso:: :class:`wx.Button` for a list of valid window styles.
.. method:: AcceptsFocus(self)
Can this window be given focus by mouse click?
.. note:: Overridden from :class:`wx.Control`.
.. method:: DoGetBestSize(self)
Overridden base class virtual. Determines the best size of the
button based on the label and bezel size.
:return: An instance of :class:`wx.Size`.
.. note:: Overridden from :class:`wx.Control`.
.. method:: DrawBezel(self, dc, x1, y1, x2, y2)
.. method:: DrawFocusIndicator(self, dc, w, h)
.. method:: DrawLabel(self, dc, width, height, dx=0, dy=0)
.. method:: Enable(self, enable=True)
Enables/disables the button.
:param bool `enable`: ``True`` to enable the button, ``False`` to disable it.
.. note:: Overridden from :class:`wx.Control`.
.. method:: GetBackgroundBrush(self, dc)
Returns the current :class:`wx.Brush` to be used to draw the button background.
:param wx.DC `dc`: the device context used to draw the button background.
.. method:: GetBezelWidth(self)
Returns the width of the 3D effect, in pixels.
:rtype: integer
.. method:: GetDefaultAttributes(self)
Overridden base class virtual. By default we should use
the same font/colour attributes as the native :class:`wx.Button`.
:return: an instance of :class:`wx.VisualAttributes`.
.. note:: Overridden from :class:`wx.Control`.
.. method:: GetUseFocusIndicator(self)
Returns the focus indicator flag, specifying if a focus indicator
(dotted line) is being used.
:rtype: bool
.. method:: InitColours(self)
Calculate a new set of highlight and shadow colours based on
the background colour. Works okay if the colour is dark...
.. method:: InitOtherEvents(self)
Override this method in a subclass to initialize any other events that
need to be bound. Added so :meth:`__init__` doesn't need to be
overridden, which is complicated with multiple inheritance.
.. method:: Notify(self)
Actually sends a ``wx.EVT_BUTTON`` event to the listener (if any).
.. method:: OnGainFocus(self, event)
Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenButton`.
:param `event`: a :class:`wx.FocusEvent` event to be processed.
.. method:: OnKeyDown(self, event)
Handles the ``wx.EVT_KEY_DOWN`` event for :class:`GenButton`.
:param `event`: a :class:`wx.KeyEvent` event to be processed.
.. method:: OnKeyUp(self, event)
Handles the ``wx.EVT_KEY_UP`` event for :class:`GenButton`.
:param `event`: a :class:`wx.KeyEvent` event to be processed.
.. method:: OnLeftDown(self, event)
Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenButton`.
:param `event`: a :class:`wx.MouseEvent` event to be processed.
.. method:: OnLeftUp(self, event)
Handles the ``wx.EVT_LEFT_UP`` event for :class:`GenButton`.
:param `event`: a :class:`wx.MouseEvent` event to be processed.
.. method:: OnLoseCapture(self, event)
Handles the ``wx.EVT_MOUSE_CAPTURE_LOST`` event for :class:`GenButton`.
:param `event`: a :class:`wx.MouseCaptureLostEvent` event to be processed.
.. method:: OnLoseFocus(self, event)
Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenButton`.
:param `event`: a :class:`wx.FocusEvent` event to be processed.
.. method:: OnMotion(self, event)
Handles the ``wx.EVT_MOTION`` event for :class:`GenButton`.
:param `event`: a :class:`wx.MouseEvent` event to be processed.
.. method:: OnPaint(self, event)
Handles the ``wx.EVT_PAINT`` event for :class:`GenButton`.
:param `event`: a :class:`wx.PaintEvent` event to be processed.
.. method:: OnSize(self, event)
Handles the ``wx.EVT_SIZE`` event for :class:`GenButton`.
:param `event`: a :class:`wx.SizeEvent` event to be processed.
.. method:: SetBackgroundColour(self, colour)
Sets the :class:`GenButton` background colour.
:param `colour`: a valid :class:`wx.Colour` object.
.. note:: Overridden from :class:`wx.Control`.
.. method:: SetBezelWidth(self, width)
Sets the width of the 3D effect.
:param integer `width`: the 3D border width, in pixels.
.. method:: SetDefault(self)
This sets the :class:`GenButton` to be the default item for
the panel or dialog box.
.. note:: Under Windows, only dialog box buttons respond to this function.
As normal under Windows and Motif, pressing return causes the
default button to be depressed when the return key is pressed. See
also :meth:`wx.Window.SetFocus` which sets the keyboard focus for
windows and text panel items, and
:meth:`wx.TopLevelWindow.SetDefaultItem`.
.. note:: Note that under Motif, calling this function immediately after
creation of a button and before the creation of other buttons will
cause misalignment of the row of buttons, since default buttons are
larger. To get around this, call :meth:`wx.SetDefault` after you
have created a row of buttons: wxPython will then set the size of
all buttons currently on the panel to the same size.
.. method:: SetForegroundColour(self, colour)
Sets the :class:`wx.GenButton` foreground colour.
:param `colour`: a valid :class:`wx.Colour` object.
.. note:: Overridden from :class:`wx.Control`.
.. method:: SetInitialSize(self, size=None)
Given the current font and bezel width settings, calculate
and set a good size.
:param `size`: an instance of :class:`wx.Size` or ``None``,
in which case the wxPython
``wx.DefaultSize`` is used instead.
.. method:: SetUseFocusIndicator(self, flag)
Specifies if a focus indicator (dotted line) should be used.
:param bool `flag`: ``True`` to draw a focus ring, ``False`` otherwise.
.. method:: ShouldInheritColours(self)
Overridden base class virtual. Buttons usually don't inherit
the parent's colours.
.. note:: Overridden from :class:`wx.Control`.
|