[wxPython-users] how to send data from dialog to main frame

C M cmpython at gmail.com
Mon Dec 3 22:56:57 PST 2007


On Nov 30, 2007 6:33 PM, Robin Dunn <robin at alldunn.com> wrote:

> C M wrote:
> >
> >
>
> >
> > Thank you.  This works, but I would like to understand why it works.
> > Questions...
> >
> > 1. If I change wx.ID_OK (in both the dialog's and frame's code) to
> > wx.ID_CANCEL it still works, but if I use wx.ID_NO or wx.ID_DELETE it
> > doesn't.  Why is that?
>
> wx.Dialog has default button handlers for buttons with an ID of wx.ID_OK
> and wx.ID_CANCEL.  If you have buttons with other IDs then you need to
> add handlers for them yourself.
>
>
> >
> > 1b. the line result =3D dlog.ShowModal () I understand, but I don't
> > understand how the act of showing the modal dialog can =3D=3D wx.ID_OK,
> > because I'm not sure what wx.ID_OK represents.
>
> The return value of ShowModal is whatever value was passed to EndModal.
>  So the default handler for the ok button calls (among other things)
> self.EndModal(wx.ID_OK) and the cancel button handler calls
> self.EndModal(wx.ID_CANCEL).  You can call EndModal from your own
> handlers with some other value if you want to do so.
>
>
> >
> > 3. What is the purpose here of wx.Dialog.ProcessEvent(self, evt)?
>
> It is resending the event.  What is probably intended is that the
> default event handler is still called even though it is caught by this
> handler.  A better way to do that is to simply call evt.Skip().
>
> BTW, you'll probably want to read the section in the book on Validators,
> as that describes another way to transfer data to/from a dialog that you
> might find to be simpler because once it is set up it is automatic.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>

Thank you for the explanations, it is helpful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200712=
04/d43a23d8/attachment.htm


More information about the wxpython-users mailing list