[英]Scroll tkinter ttk Entry text to the End in Python
I am trying to create a GUI form using Python tkinter. 我正在尝试使用Python tkinter创建一个GUI表单。 For a ttk Entry widget, I want to set a default text.
对于ttk Entry小部件,我想设置一个默认文本。 I do that using the insert() as shown below-
我使用insert()执行此操作,如下所示 -
from tkinter import *
from tkinter import ttk
root = Tk()
e = ttk.Entry(root, width=20)
e.pack()
e.insert(0, 'text greater than width of the widget')
The widget shows the beginning portion of the inserted text. 窗口小部件显示插入文本的开头部分。 Is there a way that I can make it scroll to the end of the inserted text by default?
有没有办法可以让它默认滚动到插入文本的末尾?
您可以调用xview
方法将给定索引滚动到视图中:
e.xview("end")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.