7
레이블 위젯이 줄 바꿈을하지 않습니다. 메시지 위젯은 텍스트를 줄 바꿈하지만 대략 사각형이되도록합니다. 여기에 예제가 있습니다.파이썬에서 Tkinter를 사용하여 창 너비를 채우는 줄 바꿈 텍스트를 만드는 방법은 무엇입니까?
from Tkinter import *
root = Tk()
root.title("hello")
Message(root, text=48*'xxxxx ').grid(row=0, column=0, columnspan=3)
Label(root, text='Name:').grid(row=1, column=0)
Entry(root, width=50).grid(row=1, column=1)
Button(root, text="?").grid(row=1, column=2)
Button(root, text="Left").grid(row=2, column=0)
Button(root, text="Center").grid(row=2, column=1)
Button(root, text="Right").grid(row=2, column=2)
root.mainloop()
이 나는 모양을 변경하는 aspect=700
를 사용할 수 있다는 것을 알고 있지만, 그런 하드 코딩 숫자는 내가 피하기 위해 노력하고있어입니다.
위젯이 크기를 변경할 때 랩 길이를 동적으로 변경할 수 있도록 위젯에 바인딩을 설정할 수도 있습니다. –
@JimDenny, 화면 단위는 무엇을 의미합니까? 나는 이것에 초보적이다. – heretoinfinity