Who's to blame?

Nicola Musatti nicola.musatti at gmail.com
Fri Jan 4 09:39:22 EST 2008


On Jan 4, 3:12 pm, kyoso... at gmail.com wrote:
[...]
> I have sub-classed wx.Dialog to do my own custom modal dialogs as
> well. You can use sizers and put whatever widgets you want onto it
> that way. Just make sure that when you create the Yes/No buttons, you
> give them the wx.ID_YES or wx.ID_NO ids, rather than -1 or wx.ID_ANY.
>
> yesBtn = wx.Button(parent, wx.ID_YES, 'Yes')
> noBtn  = wx.Button(parent, wx.ID_NO, 'No')

As far as I understand this should be taken care of by the XRC/
wxStdDialogButtonSizer combination.

Anyway, I solved my problem by binding the following event handler to
both buttons:

    def OnButton(self, event):
        if self.IsModal():
            self.EndModal(event.GetId())

By the way, my assumption above appears to be supported by the fact
that a call to ShowModal() on my dialog does return wx.ID_YES when I
press the Yes button. I'm still a bit puzzled, but right now I can't
afford to let it bother me too much.

Thanks for your help!

Cheers,
Nicola






More information about the Python-list mailing list