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), where r, g and b are 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 標準對話框模組