Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll tkinter ttk Entry text to the End in Python

Tags:

python

tkinter

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?

like image 718
Aditya Kumar Avatar asked Oct 19 '22 04:10

Aditya Kumar


1 Answers

You can call the xview method to scroll a given index into view:

e.xview("end")
like image 142
Bryan Oakley Avatar answered Oct 20 '22 23:10

Bryan Oakley