ColorChooserDialog
Bases: Dialog
A class which displays a color chooser dialog. When a color option is selected and the "OK" button is pressed, the dialog will return a namedtuple that contains the color values for rgb, hsl, and hex. These values can be accessed by indexing the tuple or by using the named fields.

Examples:
```python
>>> cd = ColorChooserDialog()
>>> cd.show()
>>> colors = cd.result
>>> colors.hex
'#5fb04f'
>>> colors[2]
'#5fb04f
>>> colors.rgb
(95, 176, 79)
>>> colors[0]
(95, 176, 79)
```
Source code in src/ttkbootstrap/dialogs/colorchooser.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
__init__(parent=None, title='Color Chooser', initialcolor=None)
Create a color chooser dialog.
The dialog displays a ColorChooser widget in a modal dialog with OK and Cancel buttons. When OK is pressed, the result property returns a ColorChoice namedtuple containing the selected color in multiple formats (rgb, hsl, hex). The dialog also includes a color dropper tool for selecting colors from the screen (Windows/Linux only).
Parameters:
parent (Widget):
Parent widget. The dialog will be modal and centered on this
widget.
title (str):
The dialog window title (default='Color Chooser', will be
localized).
initialcolor (str):
Initial color to display in the chooser. Can be any valid color
string format (e.g., '#FF0000', 'red', 'rgb(255,0,0)'). If None,
uses the theme's background color.
Returns:
| Type | Description |
|---|---|
None
|
The result property contains a ColorChoice namedtuple with fields: |
None
|
|
None
|
|
None
|
|
None
|
Returns None if the dialog was cancelled. |
Source code in src/ttkbootstrap/dialogs/colorchooser.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |