GUI and Desktop Modules
tkinter.colorchooser
Opens a modal color-selection dialog through askcolor(). On success it returns RGB components and a color string; cancellation returns (None, None). The result should be checked before applying a color. The example mocks a selection rather than displaying a dialog.
Formal Syntax & Structure
python syntaxpython
import tkinter.colorchooserReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from tkinter.colorchooser import askcolorfrom unittest.mock import patchwith patch("tkinter.colorchooser.Chooser.show", return_value=((255, 128, 0), "#ff8000")): rgb, color = askcolor() print(color)