滚动条小部件上的选项jump = 1
不起作用。我使用Windows10。
根据Tk手册-
“如果jump
选项为True
,则视图不会随滑块一起拖动;仅当释放鼠标按钮时,视图才会更改。”
但是它仍然与滑块一起拖动。
有什么方法可以迫使它在Windows上运行?
from tkinter import Tk, Text, Scrollbar, mainloop, INSERT
class Test(Tk):
def __init__(self):
super().__init__()
self.text = Text(self)
self.vsb = Scrollbar(self,command=self.text.yview, jump=True )
self.hsb = Scrollbar(self,command=self.text.xview,orient="horizontal")
self.text.configure(yscrollcommand=self.vsb.set,xscrollcommand=self.hsb.set)
self.text.grid(row=0, column=1)
self.vsb.grid(row=0, column=2, sticky='ns')
self.hsb.grid(row=1, column=1, sticky='ew')
for sentence in range(100):
self.text.insert(INSERT, 'This is a test sentence.\n')
root=Test()
mainloop()