| | |
Targets?
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
So two text boxes, and the text from one goes into the other?
(or do you mean MS Notepad? That would be quite a challenge).
Here's a small example:
It's not perfect -- the second Text widget is one character behind the first because the <Any-KeyPress> event is processed prior to the key being inserted into the first Text.
But it gives a decent idea.
Jeff
(or do you mean MS Notepad? That would be quite a challenge).
Here's a small example:
Python Syntax (Toggle Plain Text)
import Tkinter as tk class MyFrame(tk.Frame): def __init__(self, parent): tk.Frame.__init__(self, parent) self.text1 = tk.Text(self, width=40, height=10) self.text2 = tk.Text(self, width=40, height=10, state=tk.DISABLED) self.text1.grid() self.text2.grid() self.text1.bind("<Any-KeyPress>", self.copytext) def copytext(self, event): text = self.text1.get("0.0", tk.END) self.text2["state"]=tk.NORMAL self.text2.delete("0.0", tk.END) self.text2.insert("0.0", text) self.text2["state"]=tk.DISABLED app = tk.Tk() app.frame = MyFrame(app) app.frame.grid() app.mainloop()
It's not perfect -- the second Text widget is one character behind the first because the <Any-KeyPress> event is processed prior to the key being inserted into the first Text.
But it gives a decent idea.
Jeff
![]() |
Similar Threads
- Anti-Cheat Development Team (Software Development Job Offers)
- Help - This started out as 213.159.117.132/redir.php NOW??? (Viruses, Spyware and other Nasties)
- Possible CWS problem (Viruses, Spyware and other Nasties)
- computer turns off by itself (Windows NT / 2000 / XP)
- Java Applet viewer blinks everytime the init method is used. (Java)
- Novell World! (Novell)
- Big Game need progrmmers (C++)
- Help me with my monitor (Monitors, Displays and Video Cards)
Other Threads in the Python Forum
- Previous Thread: Search engine (please help!)
- Next Thread: Question on Integrating Python with HTML
Views: 499 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Python
alarm aliased application beginner calculator casino character code command cursor cx-freeze definedlines development dictionary dynamic error event examples excel exe file filename float format ftp function google graphics gui homework ideas import input java launcher line linux list lists logging loop matching microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook port prime program programming projects py2exe pygame pygtk pyqt pysimplewizard python random recursion recursive refresh return reverse scrolledtext shebang simple skinning sprite ssh statistics string strings table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip windows wxpython





