[Python] Tkinter를 활용하여 Text 강조(Highlight)하기






from tkinter import *
from tkinter import ttk

# Tkinter 인스턴스 생성
win = Tk()

# Window 사이즈 지정
win.geometry("700x350")

# 폰드 변경 함수 정의
def font_change():
text.tag_add("start", "1.0", "1.7")
text.tag_configure("start", background="red", foreground="white")


text=Text(win, width=80, height=15, font=('Calibri 12'))

text.insert(INSERT, "Tkinter Text background color change.\n")
text.insert(END, "Learning Tkinter")
text.pack()

# 버튼 생성
ttk.Button(win, text="Text Highlight", command=font_change).pack(pady=20)
win.mainloop()

댓글

이 블로그의 인기 게시물

[Python] Tkinter를 활용한 Text Console 출력

[Python] Tkinter를 활용하여 Entry 값 계산하여 Label에 출력