当超过参数中给出的限制时,tkinter 中标签中的文本可以换行为多行wraplength。
然而,这是一些像素,但我想为此使用完整的窗口宽度,并且只要用户更改窗口大小,环绕长度就应该更改。
一种方法是手动更新参数,如下所示:
def update_wraplength(id, root):
id.configure(wraplength=root.winfo_width())
root.after(10, lambda: update_wraplength(id,root))
Run Code Online (Sandbox Code Playgroud)
还有另一种方法可以做到这一点,也许是我不知道的参数?