[Tutor] Tutor Digest, Vol 32, Issue 72

Pine Marten pine508 at hotmail.com
Wed Oct 18 04:17:50 CEST 2006


(in reference to a question I had about how to simply save the content of a 
textCtrl to a text file)

>#Okay, here is the function we need to change.
>
>
>     def OnSaveButton(self, event):
>         #from John's save(event) function:
>         #
>         #savefile = open(self.filename, 'w')
>         #savefile.write(myTextBox.GetValue())
>         #savefile.close()
>
>         savefile = open('test.txt','w')
>         #if you don't want 'test.txt' try using a variable.
>
>
>         savefile.write(self.textCtrl1.GetValue())
>         #textCtrl1 is an attribute of your Frame1 class.
>
>
>
>         savefile.close()
>         #then we just save it.
>
>Do you understand which parts of John's examples were changed and why?
>Hope That Helps,
>-Luke

I tried it and it did work this time, thanks so much.  Your effort may keep 
me trying bit by bit to gain a little profiency.

And yes, I believe I see how much of this ought to work now.  I am just 
going to keep going over how one assigns a variable like savefile to a built 
in function like open() but then attaches a method to it such as when you 
write savefile.write.  I think if I work with that enough I will come to see 
it as intuitive; for now it still is unintuitive.   Thanks again.

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us



More information about the Tutor mailing list