Python 如何包装在列表框中
当我运行此代码时,文本将越过列表框的边界。是否有一个参数,我可以添加到这个,以便我可以得到的文本包装到下一行。我不在乎一个词的一部分是否被删掉。我试图使列表框变大,但文本仍然没有换行 谢谢使用文本小部件而不是列表框。文本小部件具有换行选项。无、字符、单词Python 如何包装在列表框中,python,Python,当我运行此代码时,文本将越过列表框的边界。是否有一个参数,我可以添加到这个,以便我可以得到的文本包装到下一行。我不在乎一个词的一部分是否被删掉。我试图使列表框变大,但文本仍然没有换行 谢谢使用文本小部件而不是列表框。文本小部件具有换行选项。无、字符、单词 from Tkinter import * root = Tk() root.title("Help") scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) hel
from Tkinter import *
root = Tk()
root.title("Help")
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
help_message = 'This is the help menu. Please scroll through the menu to find the answer to your question'
listbox = Listbox(root)
listbox.pack()
listbox.insert(END, help_message)
listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=listbox.yview)
mainloop()
from Tkinter import *
root = Tk()
root.title("Help")
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
help_message = 'This is the help menu. Please scroll through the menu to find the answer to your question'
txt = Text(root, wrap=WORD) # wrap=CHAR, wrap=NONE
txt.pack(expand=1, fill=BOTH)
txt.insert(END, help_message)
txt.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=txt.yview)
mainloop()