468,288 Members | 1,978 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,288 developers. It's quick & easy.

Write to file and see content on screen

Hello all,

New user to python. I can write to a file, however, I would like to
do both...whatever I do on the screen, I'd like to write it to a file.

any pointers on where I can find this info.

thanks,
Jun 27 '08 #1
2 1117
CM
On Jun 9, 9:01 pm, lama...@verizon.net wrote:
Hello all,

New user to python. I can write to a file, however, I would like to
do both...whatever I do on the screen, I'd like to write it to a file.

any pointers on where I can find this info.

thanks,
There is probably some smart way to do this that I don't know, but
in wxPython you could have your textbox and bind it to an EVT_TEXT
event, and then in the event handler for that write the contents of
the textbox to your file. This way on any change in the textbox,
there would be a write to the file. But I don't know if that is
practical or if the writes would keep up well. You could also have
a counter and when the counter reaches x characters then do a write.
Or you could set a timer and do the write every x seconds.

Jun 27 '08 #2
On Jun 10, 2:01 am, lama...@verizon.net wrote:
Hello all,

New user to python. I can write to a file, however, I would like to
do both...whatever I do on the screen, I'd like to write it to a file.

any pointers on where I can find this info.

thanks,
Something like this, perhaps?

class Storage(object):
def __init__(self, the_file):
self.the_file = the_file
def write(self, message):
import sys
sys.stdout.write(message)
self.the_file.write(message)

my_file = open("my_text.txt", "w")
store = Storage(my_file)
print >store, "Hello world!"
my_file.close()
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by lawrence | last post: by
13 posts views Thread by Ken | last post: by
2 posts views Thread by seans | last post: by
reply views Thread by Manuel | last post: by
4 posts views Thread by Brad | last post: by
2 posts views Thread by houghi | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.