Page 1 of 1

Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 1:42 pm
by joseplaselva
I would like to know if it is a way of dysplay the lines from top to botton in a scrolledtext widget. Now when I write a line appears allways in the top when the first one appears in the botton. When I write on a simple text widget appears in the other way, the last line is allways at the botton...
Thanks if some one can make me see the light :-)

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 4:11 pm
by Paeryn
Your description is a bit confusing,
joseplaselva wrote:
Sun May 19, 2019 1:42 pm
Now when I write a line appears allways in the top when the first one appears in the botton. When I write on a simple text widget appears in the other way, the last line is allways at the botton...
When you say write do you mean inserting text from within your program or do you mean typing text into the widget? Either way a ScrolledText widget should handle writes exactly like a Text widget does as that is what that area is.

The ScrolledText widget is just three widgets combined: a text widget, a scrollbar widget and a frame widget enclosing the text and scrollbar. The ScrolledText widget behaves like a Text widget, the only difference is that the scrollbar can change what part of the text is visible when there is more text than it can display.

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 4:20 pm
by joseplaselva
Hi , thanks for fast reply.
The text is writing by scrip as folow :

Code: Select all

    def write_line(self):
        global display_event        
        timenu = str(time.strftime("%y-%m-%d %H:%M:%S"))
        texte = timenu + "  " + display_event + " \n"
        self.textEvents.insert("1.0", texte)
        self.textEvents.update_idletasks()

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 4:23 pm
by joseplaselva
and appears in the widget as folow :

Code: Select all

19-05-19 18:20:45  =Check: Succeed mailed 
19-05-19 18:20:39  =Check: Camera:19-May-19_(182036) 
19-05-19 18:20:36  =Check: Down 1.35 Mbit | Up:0.75 Mbit 
19-05-19 18:20:00  =Check: IP: 87.125.68.81  
19-05-19 18:13:02  Starting survey every 5 minutes... 
19-05-19 18:13:02  == Initial procedures acomplished == 
19-05-19 18:13:02  ...Succeed sending mail 
19-05-19 18:12:56  Preparing to send Start-mail... 
19-05-19 18:12:56  Test ok 19-May-19_(181254).jpg 
19-05-19 18:12:54  Checking  camera... 
19-05-19 18:12:54  Down:1.37 Mbit/s | Up:0.74 Mbit/s  
19-05-19 18:12:17  Checking internet speed... 
19-05-19 18:12:17  IP: 87.125.68.81  
19-05-19 18:12:16  Checking internet connection... 
19-05-19 18:12:16  ==Starting initial procedures== 

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 5:20 pm
by Paeryn
joseplaselva wrote:
Sun May 19, 2019 4:20 pm

Code: Select all

        self.textEvents.insert("1.0", texte)
The "1.0" in the insert function says to insert the text at line 1 column 0, i.e. before anything else. To insert at the very end use

Code: Select all

        self.textEvents.insert(tk.END, texte)

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 5:30 pm
by joseplaselva
Thanks a lot , now run perfectly.
Have a nice sunday evening... and thanks again for your kind help
Cheers

Re: Question about Tkinter text widged in scrolledtext

Posted: Sun May 19, 2019 5:40 pm
by Paeryn
Glad I could help, have fun.