[Tutor] wxPython dialog problem

Kent Johnson kent37 at tds.net
Fri Feb 20 12:25:12 CET 2009


On Thu, Feb 19, 2009 at 11:04 PM, Garry Willgoose
<Garry.Willgoose at newcastle.edu.au> wrote:
> I'm just porting an old code from a GUI in Tkinter to one in wxPython and am
> having a problem with one of the dialog widgets. This is on OSX. The code
> below gives the result
>
> result= 5104 5103 5104
>
> as expected but if I substitute the single line form that is commented out
> (as per the wxPython book) I get
>
> result= 2 5103 5104
>
> can anyone enlighten me as to what is going on? I;m on OSX python 2.5.2 and
> wxPython 2.8.9.1

Apparently ShowModal() returns one of
wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO
whereas MessageBox() returns one of
wxYES, wxNO, wxCANCEL, wxOK

These are not the same:
In [1]: import wx

In [3]: wx.ID_OK, wx.ID_CANCEL, wx.ID_YES, wx.ID_NO
Out[3]: (5100, 5101, 5103, 5104)

In [4]: wx.YES, wx.NO, wx.CANCEL, wx.OK
Out[4]: (2, 8, 16, 4)

Kent
>
> code fragment
>
>  dlg=wx.MessageDialog(None,text,title,wx.YES_NO | wx.ICON_QUESTION)
>  result=dlg.ShowModal()
> #  result=wx.MessageBox(text,title,wx.YES_NO | wx.ICON_QUESTION)
>  print 'result=',result,wx.ID_YES,wx.ID_NO
>
> end code fragment
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list