| | |
Problem with Text widget Tkinter
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Hi everyone,
I have a problem to insert text into a text widget in Tkinter.
I want to be able that each time some text is inserted (by means of an action -not directly by the user-) that text is displayed into a new line.
However I can't figure out how to do this because everything I've tried showed me the same result: the new text is appended to the last character of the old text.
I've also tried to use the expression formatting, as shown in the following code excerpt, without success.
Can someone help me with this?
Thanks a lot,
Gab
I have a problem to insert text into a text widget in Tkinter.
I want to be able that each time some text is inserted (by means of an action -not directly by the user-) that text is displayed into a new line.
However I can't figure out how to do this because everything I've tried showed me the same result: the new text is appended to the last character of the old text.
I've also tried to use the expression formatting, as shown in the following code excerpt, without success.
Can someone help me with this?
python Syntax (Toggle Plain Text)
i = "%s: %s" % (self.PSprod, self.PSv) self.InfoPoint.insert("%s lineend" % INSERT, i)
Thanks a lot,
Gab
Will something like this do?
python Syntax (Toggle Plain Text)
import Tkinter as tk def set_text_newline(s): """start text s on a new line""" text1.insert(tk.INSERT, '\n' + s) root = tk.Tk() # width=width characters, height=lines of text text1 = tk.Text(root, width=50, height=12, bg='yellow') text1.pack() set_text_newline("line one") set_text_newline("line two") set_text_newline("line three") root.mainloop()
No one died when Clinton lied.
Thanks a lot!
It now works perfectly like this
Again, thank you so much
It now works perfectly like this
python Syntax (Toggle Plain Text)
self.InfoPoint.insert (INSERT, i) self.InfoPoint.insert(END, "\n")
Again, thank you so much
![]() |
Similar Threads
- try to browsing directory using TKinter but give error please help (Python)
- HELP: Tkinter Text Widget problem (Python)
- tkinter widget method problem (Python)
- Python GUI Problem (Python)
- tkinter - several problems (Python)
- Problem with find (Python)
- Tkinter: protecting text in the Entry widget (Python)
Other Threads in the Python Forum
- Previous Thread: Regex help for upper case
- Next Thread: Just started teaching myself python (functions question)
Views: 950 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
advanced anydbm app bash beginner bits calling chmod cmd code data dictionary directory dynamic edit examples excel external feet file float format ftp function gui homework http images import info input ip itunes java keycontrol line linux list lists loan loop maintain millimeter mouse newb number numbers output panel parsing path port prime program programming projects push py-mailer py2exe pygame pyqt python queue random recursion recursive scrolledtext search smtp socket split ssh statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable variables ventrilo web webservice whileloop windows wxpython






