Python Forum
[Tkinter] Tkinter Winget python text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tkinter Winget python text
#1
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.
Reply
#2
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.
Reply
#3
Thank you for your answer, I am a beginner in Python, it will not be easy to understand your procedure.
Cordially.
Marc.
Reply
#4
Just search for the parts with word 'scroll' in them.
Reply
#5
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 :-)
Reply
#6
Thanks a lot for your help.
This is exactly what I was looking for.
Cordially.
Marc.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Updating tkinter text BliepMonster 5 5,671 Nov-28-2022, 01:42 AM
Last Post: deanhystad
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,671 Jun-26-2022, 06:26 PM
Last Post: menator01
  tkinter change the text of the checkbox zazas321 1 3,756 Sep-17-2021, 06:19 AM
Last Post: zazas321
  tkinter text widget word wrap position chrisdb 6 7,459 Mar-18-2021, 03:55 PM
Last Post: chrisdb
  [Tkinter] tkinter.Menu – How to make text-variable? Sir 3 5,546 Mar-10-2021, 04:21 PM
Last Post: Sir
Photo Tkinter TEXT background image _ShevaKadu 5 7,654 Nov-02-2020, 10:34 AM
Last Post: joe_momma
  tkinter | Button color text on Click Maryan 2 3,316 Oct-09-2020, 08:56 PM
Last Post: Maryan
  [Tkinter] Text Upload LearningLittlebyLittle 0 2,014 Sep-04-2020, 07:55 PM
Last Post: LearningLittlebyLittle
  [Tkinter] Indentation for Tkinter-made Text Editor ShakeyPakey 4 5,053 Jun-08-2020, 03:13 PM
Last Post: menator01
  How to make button text bold in Tkinter? scratchmyhead 2 11,906 May-16-2020, 02:53 AM
Last Post: scratchmyhead

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020