7
ラベルウィジェットは改行しません。メッセージウィジェットはテキストの行折り返しを行いますが、強制的に正方形にします。ここに例があります。Pythonで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