Skip to content

ColorDropperDialog

Screen color picker with zoom preview.

Click anywhere on screen to select a color. The selected color is stored in result as a ColorChoice named tuple with rgb, hsl, and hex values.

Note

Supported on Windows and Linux. macOS is not supported due to ImageGrab limitations. On high-DPI displays, ensure the app runs in high-DPI mode.

__init__

__init__() -> None

Initialize the ColorDropperDialog and prepare all state attributes.

build_screenshot_canvas

build_screenshot_canvas() -> None

Build the screenshot canvas

build_zoom_toplevel

build_zoom_toplevel(master) -> None

Build the toplevel widget that shows the zoomed version of the pixels underneath the mouse cursor.

on_mouse_wheel

on_mouse_wheel(event: Event) -> None

Zoom in and out on the image underneath the mouse

on_left_click

on_left_click(_: Event) -> Optional[ColorChoice]

Capture the color underneath the mouse cursor and destroy the toplevel widget

on_right_click

on_right_click(_: Event) -> None

Close the color dropper without saving any color information

get_hover_color

get_hover_color() -> str

Get the color that is hovered over by the mouse cursor.

on_dialog_result

on_dialog_result(
    callback: Callable[[Any], None],
) -> Optional[str]

Bind a callback fired when the dropper produces a result.

off_dialog_result

off_dialog_result(funcid: str) -> None

Unbind a previously bound dialog result callback.

show

show() -> None

Show the toplevel window