class controls.ButtonBase(object)

ButtonBase 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 subclass using it.

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, this property becomes read-only and gets its value via the supplied function.

enable = None
A function of no arguments returning a boolean indicating whether the button should be enabled. May also be defined as a method in the subclass.

action = None
A function of no arguments to be called when the button is clicked. May also be defined as a method in the subclass.

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.
---