MessageBox / MessageDialog

Hello,
     Every now and then I attempt to use the return value from a
MessageBox as below,

retcode = wx.MessageBox('Save changes?', '',
                        style=wx.YES_NO|wx.ICON_QUESTION)
if retcode == wx.ID_YES:
    #do dome stuff

but the return codes don't correspond to wx.ID_YES or wx.ID_NO (I get
return codes of 2 or 8 instead). Using a MessageDialog instead solves
the issue. But I was wondering if this a known issue or if I'm just
completely misunderstanding something. I can't find any evidence of
anyone else having problems, and I do keep finding (apparently) working
examples of the above in use. Cheers. TIA.

Duncan

wxPython 2.8.8.0 Python 2.5.2 Intrepid Ibex

Hello,

···

On Jun 16, 2009, at 9:32 PM, duncan smith wrote:

Hello,
    Every now and then I attempt to use the return value from a
MessageBox as below,

retcode = wx.MessageBox('Save changes?', '',
                       style=wx.YES_NO|wx.ICON_QUESTION)
if retcode == wx.ID_YES:
   #do dome stuff

but the return codes don't correspond to wx.ID_YES or wx.ID_NO (I get
return codes of 2 or 8 instead). Using a MessageDialog instead solves
the issue. But I was wondering if this a known issue or if I'm just
completely misunderstanding something. I can't find any evidence of
anyone else having problems, and I do keep finding (apparently) working
examples of the above in use. Cheers. TIA.

Your looking for wx.YES/wx.NO/wx.CANCEL/wx.OK which match the input style parameters.

see: http://docs.wxwidgets.org/2.8.9/wx_dialogfunctions.html#wxmessagebox

Cody