python 中的文本滚动条

scrollbar of text in python

editor = Text(compiler, height=100, width=100)

editor.pack(side=LEFT,fill=BOTH)

scrollbar = Scrollbar(compiler)
scrollbar.pack(side=RIGHT)
scrollbar.config(command=editor.yview)

上图是在一次滚动整个 textView 后单击顶部滚动条按钮后拍摄的

现在,问题是我想构建一个像 PyCharm 这样的滚动条。

scrollbar.pack(side=RIGHT,fill=Y)

当我尝试上面的代码时,滚动条看起来像这样

滚动条无法正确滚动(它通过单击滚动按钮一次滚动整个,当我使用 fill=Y 它给了我巨大的滚动条,而我的 textView 中没有任何内容)。而且,我想让滚动条像 PyCharm 的滚动条一样工作。

感谢@acw1668 and @TheLizzard

editor = Text(compiler, height=100, width=100)

scrollbar = Scrollbar(compiler)
scrollbar.pack(side=RIGHT,fill=Y)
scrollbar.config(command=editor.yview)

editor.config(yscrollcommand=scrollbar.set)
editor.pack(side=LEFT,fill=BOTH)

正在运行....现在...