简体   繁体   中英

Scroll tkinter ttk Entry text to the End in Python

I am trying to create a GUI form using Python tkinter. For a ttk Entry widget, I want to set a default text. I do that using the insert() as shown below-

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM