Data in dialogs

How do I return data from various TextCtrl controls inside a dialog ? Do
I have to use SetPyData and something like that ?
I'm searching inside the dialog for methods that can actually help me but
didn't find anything useful.
Basically I have a normal dialog with 2 TextCtrl and an Ok button, I
want to fetch what I inserted inside the 2 TextCtrl when I press OK.
I understood the ShowModal bit, but I can't find the data I inserted.

TIA,
  ngw

···

--
checking for life_signs in -lKenny... no
  Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it

___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it

Hello, do you mean as follows:

import wx
               
class MyDialog(wx.Dialog):
    def __init__(self,parent):
        wx.Dialog.__init__(self,parent,-1)
        self.text1 = wx.TextCtrl(self, pos = (20, 20))
        self.text2 = wx.TextCtrl(self, pos = (120, 20))
        btn = wx.Button(self, pos = (70, 100), label = "OK")
        btn.Bind (wx.EVT_BUTTON, self.Exit)
        
    def Exit(self, evt):
        self.Close()
        
class App(wx.App):
    def OnInit(self):
        frame = wx.Frame(None, pos = (400, 0))
        d=MyDialog(None)
        d.ShowModal()
        print "Text1 contained:", d.text1.GetValue()
        print "Text2 contained:", d.text2.GetValue()
        d.Destroy()
        frame.Show(True)
        return True
           
app = App()
app.MainLoop()

···

On Tue, 22 Nov 2005 16:29:39 +0100, Nicholas Wieland <nicholas_wieland@yahoo.it> wrote:

How do I return data from various TextCtrl controls inside a dialog ? Do
I have to use SetPyData and something like that ?
I'm searching inside the dialog for methods that can actually help me but
didn't find anything useful.
Basically I have a normal dialog with 2 TextCtrl and an Ok button, I
want to fetch what I inserted inside the 2 TextCtrl when I press OK.
I understood the ShowModal bit, but I can't find the data I inserted.

TIA,
ngw

--
Franz Steinhaeusler

Hello Nicholas:

I usually create a simple class to hold the data that I want passed
back from a dialog. Then I create a GetData() method in the dialog
class, which fills up one of the data objects from the control contents,
then passes it back to the caller.

Then, I show the dialog, and wait for it to return.
When it does, I call GetData(), and only then Destroy() the dialog.

···

On 11/22/05, Nicholas Wieland <nicholas_wieland@yahoo.it> wrote:

How do I return data from various TextCtrl controls inside a dialog ? Do
I have to use SetPyData and something like that ?
I'm searching inside the dialog for methods that can actually help me but
didn't find anything useful.
Basically I have a normal dialog with 2 TextCtrl and an Ok button, I
want to fetch what I inserted inside the 2 TextCtrl when I press OK.
I understood the ShowModal bit, but I can't find the data I inserted.

TIA,
  ngw

--
checking for life_signs in -lKenny... no
        Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it

___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

*From:* Nicholas Wieland <nicholas_wieland@yahoo.it>
*To:* wxpython-users@lists.wxwidgets.org
*Date:* Tue, 22 Nov 2005 16:29:39 +0100

How do I return data from various TextCtrl controls inside a dialog ? Do
I have to use SetPyData and something like that ?
I'm searching inside the dialog for methods that can actually help me
but
didn't find anything useful.
Basically I have a normal dialog with 2 TextCtrl and an Ok button, I
want to fetch what I inserted inside the 2 TextCtrl when I press OK.
I understood the ShowModal bit, but I can't find the data I inserted.

There are probably others who can explain it better than I can, but
basically, when the dialog disappears from view after you press OK or
Cancel, the dialog object still exists - which is why you need to call its
Destroy() method when you have finished with it.

If your two TextCtrl's in the dialog are called, say, self.field1 and
self.field2, then do something like:

    if dlg.ShowModal() == wx.ID_OK: # ignore if wx.ID_CANCEL
        value1 = dlg.field1.GetValue()
        value2 = dlg.field2.GetValue()
    dlg.Destroy()
    
Regards,

David

- Nicholas Wieland :

CUT

Thank you very much, I've resolved the problem thanks to the suggestion
made.

  ngw

···

--
checking for life_signs in -lKenny... no
  Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it

___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it