每当我用文本填充框时,水平滚动条都可以正常工作,直到在屏幕上看到文本。
但是,如果行数大于屏幕上可以看到的行数并且我向下滚动文本,水平滚动条将变为非活动状态,直到文本太长而无法再次容纳一行
这是我真正的基本代码:
from Tkinter import *
import Tkinter,tkFileDialog, tkFont
w = Label(root, text="Hello, world!")
w.pack()
textfr=Frame(root)
t=Text(textfr, width=100, height=10,font=("Arial",12),wrap=NONE)
t.insert('1.0', 'here is my text to insert')
Yscroll=Scrollbar(textfr, orient=VERTICAL)
Xscroll=Scrollbar(textfr, orient=HORIZONTAL)
t.configure(yscrollcommand=Yscroll.set)
t.configure(xscrollcommand=Xscroll.set)
Yscroll.config(command=t.yview)
Xscroll.config(command=t.xview)
#pack everything
Yscroll.pack(side=RIGHT,fill=Y)
Xscroll.pack(side=BOTTOM,fill=X)
t.pack(side=LEFT, fill=BOTH, expand=TRUE)
textfr.pack(side=TOP, fill=BOTH, expand=TRUE)
root.mainloop()
唉,我找不到/谷歌正确的解决方案,即使问题真的很基本
有任何想法吗?