Python Forum

Full Version: Tkinter Winget python text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I use a text winget, when the window is full how to automatically scroll the text upwards to see the last line displayed.

Example.

from tkinter import *  
 
root = Tk()         
root.geometry('180x120')
 
texte =  "***Pret***\n"
## winget texte
Console = Text(root,height=5, width=20, wrap='word',)
Console.place(x = 0, y = 0)
## Ajout du texte
Console.insert(END, texte)
for i in range (20):
    print("Texte : ",i)
    Console.insert(END, "Texte : "),Console.insert(END, i),Console.insert(END, "\n")


In the window the display stops at "Texte : 3", to see "Texte : 19", I have to scroll the text with the mouse wheel.

I would like the last line to always be visible.

Do you have an idea.

Cordially.
Marc.
I use scrolling on text widget in this app: https://python-forum.io/Thread-Show-Inst...ht=tkinter
This was written a few years back, but concept is the same today.
Thank you for your answer, I am a beginner in Python, it will not be easy to understand your procedure.
Cordially.
Marc.
Just search for the parts with word 'scroll' in them.
Hi Marc

Try out the following snippet:
from tkinter import *  
  
root = Tk()         
root.geometry('180x120')
  
texte =  "***Pret***\n"
## winget texte
Console = Text(root,height=5, width=20, wrap='word',)
Console.place(x = 0, y = 0)
## Ajout du texte
Console.insert(END, texte)
for i in range (20):
    print("Texte : ",i)
    Console.insert(END, "Texte : "),Console.insert(END, i),Console.insert(END, "\n")
Console.see(END)
root.mainloop()
wuf :-)
Thanks a lot for your help.
This is exactly what I was looking for.
Cordially.
Marc.