phoenix_title wx.lib.checkbox.GenCheckBox

A generic class that replicates some of the functionalities of wx.Checkbox, while being completely owner-drawn with a nice check bitmaps.


class_hierarchy Class Hierarchy

Inheritance diagram for class GenCheckBox:

super_classes Known Superclasses

wx.Control


method_summary Methods Summary

__init__

Default class constructor.

AcceptsFocus

Overridden base class virtual.

AcceptsFocusFromKeyboard

Overridden base class virtual.

DoGetBestSize

Overridden base class virtual. Determines the best size of the control

Draw

Actually performs the drawing operations, for the bitmap and

Enable

Enables/Disables GenCheckBox.

GetBitmap

Returns the appropriated bitmap depending on the checking state

GetDefaultAttributes

Overridden base class virtual. By default we should use

GetSpacing

Returns the spacing between the check bitmap and the text.

GetValue

Returns the state of GenCheckBox, True if checked, False otherwise.

HasFocus

Returns whether or not we have the focus.

InitializeBitmaps

Initializes the check bitmaps.

InitializeColours

Initializes the focus indicator pen.

IsChecked

This is just a maybe more readable synonym for GetValue: just as the

OnKeyEvent

Handles the wx.EVT_KEY_UP or wx.EVT_KEY_UP event (depending on

OnKillFocus

Handles the wx.EVT_KILL_FOCUS event for GenCheckBox.

OnMouseClick

Handles the wx.EVT_LEFT_DOWN event for GenCheckBox.

OnPaint

Handles the wx.EVT_PAINT event for GenCheckBox.

OnSetFocus

Handles the wx.EVT_SET_FOCUS event for GenCheckBox.

OnSize

Handles the wx.EVT_SIZE event for GenCheckBox.

SendCheckBoxEvent

Actually sends the wx.wxEVT_COMMAND_CHECKBOX_CLICKED event.

SetBackgroundColour

Overridden base class virtual.

SetFont

Sets the GenCheckBox text font and updates the control’s

SetForegroundColour

Overridden base class virtual.

SetLabel

Sets the GenCheckBox text label and updates the control’s

SetSpacing

Sets a new spacing between the check bitmap and the text.

SetValue

Sets the GenCheckBox to the given state. This does not cause a

ShouldInheritColours

Overridden base class virtual. If the parent has non-default


api Class API

class GenCheckBox(wx.Control)

A generic class that replicates some of the functionalities of wx.Checkbox, while being completely owner-drawn with a nice check bitmaps.


Methods

__init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name="GenCheckBox")

Default class constructor.

Parameters
  • parent (wx.Window) – Pointer to a parent window. Must not be None.

  • id (int) – Window identifier. wx.ID_ANY indicates a default value.

  • label (str) – Text to be displayed next to the checkbox.

  • pos (wx.Point) – Window position. The value wx.DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.

  • size (wx.Size) – Window size. The value wx.DefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform.

  • style (long) – Window style. Not used in this widget, GenCheckBox has only 2 state.

  • validator (wx.Validator) – Window validator.

  • name (str) – Window name.



AcceptsFocus(self)

Overridden base class virtual.



AcceptsFocusFromKeyboard(self)

Overridden base class virtual.



DoGetBestSize(self)

Overridden base class virtual. Determines the best size of the control based on the label size, the bitmap size and the current font.



Draw(self, dc)

Actually performs the drawing operations, for the bitmap and for the text, positioning them centered vertically.

Parameters

dc (wx.DC) – device context to use.



Enable(self, enable=True)

Enables/Disables GenCheckBox.

Parameters

enable (bool) – Set the enabled state of the checkbox.



GetBitmap(self)

Returns the appropriated bitmap depending on the checking state (Checked/UnChecked) and the control state (Enabled/Disabled).



GetDefaultAttributes(self)

Overridden base class virtual. By default we should use the same font/colour attributes as the native wx.CheckBox.



GetSpacing(self)

Returns the spacing between the check bitmap and the text.



GetValue(self)

Returns the state of GenCheckBox, True if checked, False otherwise.



HasFocus(self)

Returns whether or not we have the focus.



InitializeBitmaps(self)

Initializes the check bitmaps.



InitializeColours(self)

Initializes the focus indicator pen.



IsChecked(self)

This is just a maybe more readable synonym for GetValue: just as the latter, it returns True if the GenCheckBox is checked and False otherwise.



OnKeyEvent(self, event)

Handles the wx.EVT_KEY_UP or wx.EVT_KEY_UP event (depending on platform) for GenCheckBox.

Parameters

event (wx.KeyEvent) – A wx.KeyEvent to be processed.



OnKillFocus(self, event)

Handles the wx.EVT_KILL_FOCUS event for GenCheckBox.

Parameters

event (wx.FocusEvent) – A wx.FocusEvent to be processed.



OnMouseClick(self, event)

Handles the wx.EVT_LEFT_DOWN event for GenCheckBox.

Parameters

event (wx.MouseEvent) – A wx.MouseEvent to be processed.



OnPaint(self, event)

Handles the wx.EVT_PAINT event for GenCheckBox.

Parameters

event (wx.PaintEvent) – A wx.PaintEvent to be processed.



OnSetFocus(self, event)

Handles the wx.EVT_SET_FOCUS event for GenCheckBox.

Parameters

event (wx.FocusEvent) – A wx.FocusEvent to be processed.



OnSize(self, event)

Handles the wx.EVT_SIZE event for GenCheckBox.

Parameters

event (wx.SizeEvent) – A wx.SizeEvent to be processed.



SendCheckBoxEvent(self)

Actually sends the wx.wxEVT_COMMAND_CHECKBOX_CLICKED event.



SetBackgroundColour(self, colour)

Overridden base class virtual.

Parameters

colour (wx.Colour) – Set the background colour of the checkbox.



SetFont(self, font)

Sets the GenCheckBox text font and updates the control’s size to exactly fit the label plus the bitmap.

Parameters

font (wx.Font) – Font to be used to render the checkboxs label.



SetForegroundColour(self, colour)

Overridden base class virtual.

Parameters

colour (wx.Colour) – Set the foreground colour of the checkboxs label.



SetLabel(self, label)

Sets the GenCheckBox text label and updates the control’s size to exactly fit the label plus the bitmap.

Parameters

label (str) – Text to be displayed next to the checkbox.



SetSpacing(self, spacing)

Sets a new spacing between the check bitmap and the text.

Parameters

spacing (int) – Set the amount of space between the checkboxs bitmap and text.



SetValue(self, state)

Sets the GenCheckBox to the given state. This does not cause a wx.wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.

Parameters

state (bool) – Set the value of the checkbox. True or False.



ShouldInheritColours(self)

Overridden base class virtual. If the parent has non-default colours then we want this control to inherit them.