bootstack.dialogs.ColorChooserDialog#

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

Bases: object

A dialog for choosing a color using a hue/saturation spectrum.

The chooser shows a full-spectrum canvas with a luminance slider below it. Numeric fields on the right allow direct entry in RGB, HSL, or hex notation. A screen dropper (unavailable on macOS) lets the user sample any pixel on the desktop.

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

  • color (str | None) – Initial 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