我正在创建一个简单的程序,在tkinter的列表框中显示文本。有时我要显示的文本比列表框大,因此它不在屏幕上。我想知道是否有办法让文本在屏幕下方开始新行而不是离开屏幕。
码
from tkinter import *
root = Tk()
message = "This message is too long to display on the listbox. I hope.
that someone will help me find a solution to this problem."
listBox = Listbox(root, width = 50, height=15, bg="#2C2F33", fg="white")
listBox.grid(row=0, column=0, padx=10)
listBox.insert(END, message)
listBox.see(END)
root.mainloop()
问题:
预期结果:
非常感谢所有帮助!
列表框小部件是菜单项,可供选择。列表框项目不可能分布在多于一行或多行中。
您应该使用另一个名为Text的小部件