Tkinter는 완전한 기능의 응용 프로그램을 만들 수 있는 다양한 모듈과 클래스 라이브러리를 제공합니다. Tkinter는 또한 응용 프로그램의 구성 요소와 뼈대를 빌드하기 위한 위젯을 제공합니다. 색상 선택기 tkinter의 모듈은 사용자가 선호도에 따라 위젯의 배경색을 선택하고 설정할 수 있도록 방대한 색상 세트를 제공하는 모듈 중 하나입니다.
colorchooser를 추가하려면 애플리케이션의 기능을 사용하려면 먼저 "from tkinter import colorchooser"를 사용하여 프로그램에서 이 모듈을 가져와야 합니다. . 다음으로 colorchooser.askuser()를 사용하여 색상 팔레트를 표시하는 변수를 만듭니다. .
팔레트의 모든 색상은 색인 번호로 구분되고 색인화되므로 색상이 시작되는 튜플을 지정할 수 있습니다. 마지막으로 배경색을 주어진 변수로 묶어 위젯의 색상을 변경합니다.
예시
예를 들어 이것을 이해합시다.
# Import the library
from tkinter import *
from tkinter import colorchooser
# Create an instance of window
win=Tk()
# Set the geometry of the window
win.geometry("700x350")
# Create a label widget
label=Label(win, text="This is a new Label text", font=('Arial 17 bold'))
label.place(relx=0.5, rely=0.2, anchor = CENTER)
# Call the function to display the color palette
color=colorchooser.askcolor()
# Initialize the color range by picking up the first color
colorname=color[1]
# Configure the background color
win.configure(background=colorname)
win.mainloop() 출력
위의 코드를 실행하면 레이블 위젯과 사용자에게 색상을 선택하도록 요청하는 색상 팔레트가 있는 창이 표시됩니다.

선택한 색상이 창의 배경색에 반영됩니다.
