class controls.BaseButton(object)

BaseButton is a mixin class for use by widgets having button-like behaviour. It provides handlers for mouse events that maintain a "highlighted" state, support for enabling and disabling the button, and support for calling a function when the button is clicked.

It does not provide any functionality for drawing; that is the responsibility of the class using it.

Constructor

BaseButton(action, enable)
If action is not None, it should be a function to be called when the button is clicked.
If enable is not None, it should be a function returning a boolean indicating whether the button should be enabled. In this case, the supplied function overrides the default behaviour of the enabled property.

Properties

enabled
A boolean indicating whether the button is enabled. By default, this property is read-write and maintains its own state internal to the object. When an enable function is provided in the constructor, this property becomes read-only and gets its value via the supplied function.

Attributes

highlighted
True if the button should be displayed in a highlighted state. This attribute is maintained by the default mouse handlers.

Abstract Methods

action()
This method is called when the button is clicked and the mouse is released within the button. The default implementation does nothing. This method is overwritten if an action function is provided in the constructor.
---