Tkinter에는 응용 프로그램 개발자가 강력하고 기능이 뛰어난 응용 프로그램을 빌드하는 데 도움이 되는 많은 내장 기능과 속성이 있습니다. Tkinter의 configure 메소드를 사용하여 위젯의 배경색, 전경색 및 기타 속성과 같은 속성을 설정할 수 있습니다.
위젯의 배경색이나 전경색을 설정하려면 기본 색상 코드와 RGB 색상 코드를 모두 사용할 수 있습니다. RGB는 R, G, B 값의 다른 숫자를 포함하는 6자리 영숫자로 정의됩니다. tkinter에서 RGB 색상 코드를 사용하려면 #aab123. 형식을 사용하여 정의해야 합니다.
예시
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame
win = Tk()
# Set the size of the tkinter window
win.geometry("700x350")
# Configure the color of the window
win.configure(bg='#65A8E1')
# Define the style for combobox widget
style = ttk.Style()
style.theme_use('xpnative')
# Define an event to close the window
def close_win(e):
win.destroy()
# Add a label widget
label = ttk.Label(win, text="Eat, Sleep, Code and Repeat", font=('Times New Roman italic', 22), background="black", foreground="white")
label.place(relx=.5, rely=.5, anchor=CENTER)
win.mainloop() 출력
위의 코드를 실행하면 일부 사용자 정의 배경색이 있는 창이 표시됩니다.

이제 창의 배경색을 변경하는 새로운 색상 코드를 찾으세요.