wxPython and how to return text entry to main program?

kyosohma at gmail.com kyosohma at gmail.com
Fri Apr 20 10:08:24 EDT 2007


On Apr 19, 9:05 pm, Steve Holden <s... at holdenweb.com> wrote:
> 7stud wrote:
> > On Apr 19, 1:38 pm, Tyler <hayes.ty... at gmail.com> wrote:
>
> [after quoting umpteen lines of code]
>
>
>
>
>
> > You can do this:
>
> > ---
> > class MyFrame(wx.Frame):
>
> > ..
> > ..
> > ..
> >     def OnSubmit(self, event):
> >         globals()["userInput"] = self.txtCtrlName.GetValue()
> >         self.Close()
>
> > app = MyApp()
> > app.MainLoop()
>
> > print userInput
> > -----
>
> Please try to limit your quoting to what's relevant.
>
> regards
>   Steve
> --
> Steve Holden       +44 150 684 7255  +1 800 494 3119
> Holden Web LLC/Ltd          http://www.holdenweb.com
> Skype: holdenweb    http://del.icio.us/steve.holden
> Recent Ramblings      http://holdenweb.blogspot.com

Steve,

I think Tyler is opening a custom dialog from his main GUI
application. He should have used "ShowModal" if he was using one of
wxPython's standard dialog boxes, but since he was creating his own
custom one he didn't need to, which is why I told him to use the
self.Close(True) method to destroy the dialog. Then again, maybe I am
being "wrong-headed" about the whole thing.

I was trying to come up with the "instance variable" way of storing
the variables, but I could not think of how to implement it last
night. Here are some other threads on the topic that I thought were
interesting:

http://mail.python.org/pipermail/tutor/2005-May/038648.html
http://lists.wxwidgets.org/archive/wxPython-users/msg06482.html
http://www.daniweb.com/techtalkforums/thread60439.html

Mike




More information about the Python-list mailing list