bootstack.dialogs.ColorChooserDialog#

class bootstack.dialogs.ColorChooserDialog(*, title='', value=None, parent=None)#

Bases: object

A dialog for choosing a color.

The chooser has two tabs: a Themed tab of the active theme’s color bands, and a Custom tab with a hue/saturation spectrum and luminance slider. Numeric fields on the right allow direct entry in RGB, HSL, or hex notation.

Parameters:
  • title (str) – Dialog window title. Defaults to the localized “Color” string.

  • value (str | None) – Pre-selected color as a hex string (e.g. '#ff0000'). Defaults to the current theme background color.

  • parent (Any) – Parent widget. Defaults to the active root window.

property result: ColorChoice | None#

The selected color, or None if canceled.

Returns a ColorChoice namedtuple with three attributes:

  • rgb(r, g, b) tuple, each 0–255.

  • hsl(h, s, l) tuple: hue 0–360, saturation and luminance 0–100.

  • hex — lowercase hex string, e.g. '#ff0000'.

show(*, position=None, modal=True)#

Display the dialog and block until it is closed.

Parameters:
  • position (tuple[int, int] | None) – Explicit (x, y) screen coordinates for the dialog. Defaults to centered on the parent window.

  • modal (bool) – Block the parent window until closed. Default True.

Returns:

self — allows chaining – dlg = ColorChooserDialog(...).show(); dlg.result.

Return type:

ColorChooserDialog