[Tutor] Tutor Digest, Vol 32, Issue 69
Pine Marten
pine508 at hotmail.com
Tue Oct 17 06:03:04 CEST 2006
Thank you John for the code but I still can't get it to work and to simply
save the contents of the text box to a file. Here is the code I have which
just makes a panel with a text control and two buttons, "Save" and "Save
As..." My hope is this can easily incorporate the changes you suggest, but
I can't figure out how to do it:
#Boa:Frame:Frame1
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1SAVE, wxID_FRAME1SAVEAS,
wxID_FRAME1TEXTCTRL1, ] = [wx.NewId() for _init_ctrls in range(5)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(367, 109), size=wx.Size(402, 489),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(394, 455))
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1',
parent=self,
pos=wx.Point(0, 0), size=wx.Size(394, 455),
style=wx.TAB_TRAVERSAL)
self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1,
name='textCtrl1',
parent=self.panel1, pos=wx.Point(40, 56), size=wx.Size(264,
248),
style=wx.TE_MULTILINE, value='textCtrl1')
self.Save = wx.Button(id=wxID_FRAME1SAVE, label='Save', name='Save',
parent=self.panel1, pos=wx.Point(152, 32), size=wx.Size(75,
23),
style=0)
self.Save.Bind(wx.EVT_BUTTON, self.OnSaveButton, id=wxID_FRAME1SAVE)
self.saveas = wx.Button(id=wxID_FRAME1SAVEAS, label='Save as...',
name='saveas', parent=self.panel1, pos=wx.Point(232, 32),
size=wx.Size(75, 23), style=0)
self.saveas.Bind(wx.EVT_BUTTON, self.OnSaveasButton,
id=wxID_FRAME1SAVEAS)
def __init__(self, parent):
self._init_ctrls(parent)
def OnSaveButton(self, event):
event.Skip()
def OnSaveasButton(self, event):
event.Skip()
If you or someone could show me how to insert the save function into this
properly so I can get it to work in this simple case, I think I'll
understand it better. In the meantime I will continue trying, and I will
read up on Alan's suggestion about learning to open, write, and close files
generally.
Thank you,
PM
_________________________________________________________________
Try Search Survival Kits: Fix up your home and better handle your cash with
Live Search!
http://imagine-windowslive.com/search/kits/default.aspx?kit=improve&locale=en-US&source=hmtagline
More information about the Tutor
mailing list