wxPython TextCtrl overwriting

Chris h_j_fong at hotmail.com
Sat Jul 27 15:43:02 EDT 2002


So, with a couple hints from this group, I've created my first windows
application.  I have one quick question about improving my program
(I'll have more, but I don't like to ask questions till I've exhausted
myself trying it first):

In my GUI I'm using a fairly standard dirDialog to get a path, with a
line for manual entry or the browse button beneath.  How do I write
the selected path *over* the default text currently in the box.  Seems
like it should be a one-liner (.replace, .erase, .clear,
.overwrite???).  Currently I am using .write, which appends it.
Essentially I want to start with a default value in the box, allow
someone to browse and overwrite, or manually edit the path in the box,
and then whatever's in the box when they hit ok, gets passed.

---I have a sizer with manual entry box and browse button:

self.dataentry7 = wxTextCtrl(self, ID_DIRcsvstxt, default7, size=(125,
-1))
self.button7 = wxButton(self, ID_DIRcsvsbut, 'Browse...')

----Events:

EVT_TEXT(self, ID_DIRcsvstxt,    self.EvtText7)
EVT_BUTTON(self, ID_DIRcsvsbut,  self.getDir7) 

--- And functions:

    def EvtText7(self, event):
        global text7
        text7 = event.GetString()

    def getDir7(self,event):
        dlg = wxDirDialog(self)
        if dlg.ShowModal() == wxID_OK:
             global text7
             dirname7= dlg.GetPath()
             self.dataentry7.write(dirname7)
             text7 = str(dirname7)
        dlg.Destroy()

----

"text7" is the path that I later pass to my main program.

Thanks
Chris



More information about the Python-list mailing list