fsleyes_widgets.colourbutton

This module provides the ColourButton class, a button which allows the user to select a RGBA colour.

class fsleyes_widgets.colourbutton.ColourButton(parent, size=None, colour=None)

Bases: wx._core.Button

A wx.Button which allows the user to select a colour.

The currently selected colour is displayed as a bitmap on the button. When the user presses the button, a wx.ColourDialog is displayed, allowing the user to change the colour. When the user does so, a EVT_COLOUR_BUTTON_EVENT is generated.

This class provides an alternative to the wx.ColourPickerCtrl, which is a bit inflexible w.r.t. sizing/automatic resizing.

Create a ColourButton.

Parameters
  • parent – A wx parent window.

  • size – A tuple containing the (width, height) of the colour bitmap in pixels. Defaults to (32, 32).

  • colour – Initial colour. Defaults to black.

__init__(parent, size=None, colour=None)

Create a ColourButton.

Parameters
  • parent – A wx parent window.

  • size – A tuple containing the (width, height) of the colour bitmap in pixels. Defaults to (32, 32).

  • colour – Initial colour. Defaults to black.

GetValue()

Return the current colour, as a tuple of (r, g, b, a) values, each in the range [0 - 255].

SetValue(colour)

Sets the current colour to the specified colour.

_ColourButton__onClick(ev)

Called when this ColourButton is pressed.

Displays a wx.ColourDialog allowing the user to select a new colour.

_ColourButton__updateBitmap(colour)

Called when the colour is changed. Updates the bitmap shown on the button.

__module__ = 'fsleyes_widgets.colourbutton'
fsleyes_widgets.colourbutton.EVT_COLOUR_BUTTON_EVENT = <wx.core.PyEventBinder object>

Identifier for the ColourButtonEvent.

fsleyes_widgets.colourbutton.ColourButtonEvent

alias of wx.lib.newevent.NewEvent.<locals>._Event