How do I save the contents of a text buffer
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sat Feb 17 19:38:52 EST 2007
En Sat, 17 Feb 2007 20:47:20 -0300, <google at orcon.net.nz> escribió:
> I'm using Python with pygtk and have this problem - I have read the
> contents of a file into the text buffer with this code,
>
> infile = open("mytextfile", "r")
> if infile:
> string = infile.read()
> infile.close()
> textbuffer.set_text(string)
Note that "if infile" does nothing: either the open succeeds and you get a
file object which is *always* True, or the open fails and raises an
exception and the code below never executes.
> As a test, I tried to write the buffer back to a file with this code
> but did not work,
"did not work" means...
--
Gabriel Genellina
More information about the Python-list
mailing list