[wxPython] Getting return value of dialog

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Getting return value of dialog

Paul Sokolovsky-4
Hello wxpython-users,

  I have dialog which has complex result value (e.g. list). How can I
pass that value to the caller? wxDialog has SetReturnCode() function
which sets value afterwords returned by ShowModal(). But it allows
only integer argument.

  Other idea is having in dialog special method to get its return
value, say, GetValue(). Suppose now it works by combining values of
dialog's child conytrol. Then, dialog must be non-destroyed for
GetValue() to work. But when I press window-manager close window
button, dialog automagically destroyed, so I have to override close
event handler...

  Isn't it too complicated? Is there other method? What about allowing
SetReturnCode() to return any Python value in wxPython?

Best regards,
 Paul                          mailto:[hidden email]



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Getting return value of dialog

Robin Dunn
>   I have dialog which has complex result value (e.g. list). How can I
> pass that value to the caller? wxDialog has SetReturnCode() function
> which sets value afterwords returned by ShowModal(). But it allows
> only integer argument.
>
>   Other idea is having in dialog special method to get its return
> value, say, GetValue(). Suppose now it works by combining values of
> dialog's child conytrol. Then, dialog must be non-destroyed for
> GetValue() to work. But when I press window-manager close window
> button, dialog automagically destroyed, so I have to override close
> event handler...
>

The default EVT_CLOSE handler already sets the return code to wxID_CANCEL so
you don't need to worry about dealing with this event if you do something
like this:

    dlg = MyDialog()
    if dlg.ShowModal() != wxID_CANCEL:
        val = dlg.MyGetValue()
        # do something with dlg's data...
    dlg.Destroy()


>   Isn't it too complicated? Is there other method?

There will be soon.  The next thing on my list is the wxValidator classes.
(If the CVS server doesn't come back soon, I may have it done in time for
this release.)  Not only can they be used to validate the contents of
controls, but also to automatically transfer data to and from variables
external to the Dialog.

> What about allowing
> SetReturnCode() to return any Python value in wxPython?

This is a good idea but would probably interfere too much with the default
handling of wxID_OK and wxID_CANCEL.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users