텍스트 위젯은 사용자의 여러 줄 사용자 입력을 지원합니다. configure()를 사용하여 글꼴 속성, 텍스트 색상, 배경 등과 같은 텍스트 위젯 속성을 구성할 수 있습니다. 방법.
Text 위젯 내에서 텍스트의 정당성을 설정하려면 tag_add()를 사용할 수 있습니다. 및 tag_configure() 속성. "정당화"의 값을 지정합니다. 중앙으로 .
예시
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the tkinter window
win.geometry("700x350")
# Create a text widget
text=Text(win, width=40, height=10)
# justify the text alignment to the center
text.tag_configure("center", justify='center')
text.insert(INSERT, "Welcome to Tutorialspoint...")
# Add the tag from start to end text
text.tag_add("center", 1.0, "end")
text.pack()
win.mainloop() 출력
위의 코드를 실행하면 텍스트 창의 커서가 가운데로 정렬되는 것을 볼 수 있습니다.
