[英]Python Tkinter Text-Widget scroll to specific line
Issue: 问题:
So far I could not find any way to scroll to a specific line in a Tkinter text-widget. 到目前为止,我找不到任何方式可以滚动到Tkinter文本小部件中的特定行。 Since Tkinter always uses the line/column (eg "1.0") notation to identify positions in the text-widget, isn't there a way to directly scroll to a given position? 由于Tkinter始终使用行/列(例如“ 1.0”)符号来标识文本小部件中的位置,因此没有办法直接滚动到给定位置吗?
So far I tried setting the yview directly: 到目前为止,我尝试直接设置yview:
textWidget.yview("scroll", scrollamount, "units")
But that seems very unclean to me to use the "units" here... 但这对我来说在这里使用“单位”似乎很不干净...
Looking for a clean solution. 寻找干净的解决方案。 Thanks. 谢谢。
>>> help(Tkinter.Text.see)
Help on method see in module Tkinter:
see(self, index) unbound Tkinter.Text method
Scroll such that the character at INDEX is visible.
To make sure line 3 is visible do: 要确保第3行可见,请执行以下操作:
textWidget.see('3.0')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.