tkinter.colorchooser --- 颜色选择对话框¶
源代码: Lib/tkinter/colorchooser.py
tkinter.colorchooser 模块提供了 Chooser 类作为原生颜色选取器对话框的接口。Chooser 实现了一个模态颜色选择对话框窗口。Chooser 类继承自 Dialog 类。
- class tkinter.colorchooser.Chooser(master=None, **options)¶
The class implementing the modal color-choosing dialog. Most applications use the
askcolor()convenience function rather than instantiating this class directly.
- tkinter.colorchooser.askcolor(color=None, **options)¶
Show a modal color-choosing dialog and return the chosen color. color is the color selected when the dialog opens. The return value is a tuple
((r, g, b), hexstr), wherer,gandbare the red, green and blue components as integers in the range 0–255 and hexstr is the equivalent Tk color string, such as'#ff8000'. If the user cancels the dialog,(None, None)is returned.在 3.10 版本发生变更: The RGB values in the returned color are now integers in the range 0–255 instead of floats.
参见
- 模块
tkinter.commondialog Tkinter 标准对话框模块