fsleyes.controls.colourbar

This module provides the ColourBar class, which generates a bitmap rendering of a colour bar.

class fsleyes.controls.colourbar.ColourBar(overlayList, displayCtx)

Bases: __main__.MockClass, __main__.MockClass

A ColourBar is an object which listens to the properties of a ColourMapOpts instance, and automatically generates a colour bar bitmap representing the current colour map properties.

Whenever the colour bar is refreshed, a notification is emitted via the Notifier interface.

orientation = <MagicMock name='mock.Choice()' id='4123093036'>

Whether the colour bar should be vertical or horizontal.

labelSide = <MagicMock name='mock.Choice()' id='4123093036'>

Whether the colour bar labels should be on the top/left, or bottom/right of the colour bar (depending upon whether the colour bar orientation is horizontal/vertical).

textColour = <MagicMock name='mock.Colour()' id='4121334444'>

Colour to use for the colour bar label.

bgColour = <MagicMock name='mock.Colour()' id='4121334444'>

Colour to use for the background.

showLabel = <MagicMock name='mock.Boolean()' id='4122918732'>

Toggle the colour bar label (the Display.name property).

showTicks = <MagicMock name='mock.Boolean()' id='4122918732'>

Toggle the tick labels (the ColourMapOpts.displayRange).

__init__(overlayList, displayCtx)

Create a ColourBar.

Parameters:
name

Return the name of this ColourBar, used internally for registering property listeners.

_ColourBar__clearColourBar(*a)

Clears any previously generated colour bar bitmap.

_ColourBar__deregisterOverlay()

Called when the selected overlay changes. De-registers property listeners from any previously-registered ColourMapOpts instance.

_ColourBar__registerOverlay()

Called when the selected overlay changes. Registers property listeners with the ColourMapOpts instance associated with the newly selected overlay.

_ColourBar__selectedOverlayChanged(*a)

Called when the OverlayList or the DisplayContext.selectedOverlay changes.

If the newly selected overlay is being displayed with a ColourMapOpts instance, various property listeners are registered, and the colour bar is refreshed.

__module__ = 'fsleyes.controls.colourbar'
destroy()

Must be called when this ColourBar is no longer needed.

Removes all registered listeners from the OverlayList, DisplayContext, and foom individual overlays.

colourBar(w, h, scale=1)

Returns a bitmap containing the rendered colour bar, rendering it if necessary.

Parameters:
  • w – Width in pixels
  • h – Height in pixels
  • scale – DPI scaling factor, if applicable.