[wxPython] switching on return codes from wxDialog family

Hi All,
I have a GUI containing a canvas(wxScrolledWindow) with many shapes on
it. I want to right click on a shape and produce some kind of *menu* with
a choice of three items (help, properties and close).
Using wxDialog, wxFrame and wxMiniFrame, and after pressing one of the
buttons on my *menu*, all seem to only return two codes, namely wxID_OK
and wxID_CANCEL. I need three return codes to be able to determine which
button was pressed.
Additionally, I need the *menu* window to be MODAL, which means that when
the menu is displayed, the GUI waits until one of the three buttons are
depressed.
Can someone please tell me if there is a more suitable CLASS to use than
those listed above, or tell me if any of the above classes return more
than just the two codes listed above.
---<snip>---
ID_miniFrame_HELP = wxID_OK #<-- pressing a button with these
ID_miniFrame_PARAM = wxID_CANCEL #<-- ID's closes the dialog and
ID_miniFrame_CANCEL= wxID_NO allows me to tell which button
                                         was pressed (see below)
<...>

win = wxDialog(self, -1, "Select an option:", (-1,-1), (-1,-1) )

wxButton(win, ID_miniFrame_HELP, "A", wxPoint( 6, 10), wxSize(150,30) )
wxButton(win, ID_miniFrame_PARAM, "B", wxPoint( 6, 50), wxSize(150,30) )
wxButton(win, ID_miniFrame_CANCEL, "C", wxPoint( 6, 90), wxSize(150,30) )

val = win.ShowModal()

if val == ID_miniFrame_HELP:
    self.displayHelp(shapeUnderMouse)
elif val == ID_miniFrame_PARAM:
    print 'do params'

---<snip>---
In the above code, pressing the HELP and PARAM buttons dismiss the *menu*
window. The CANCEL button does not cancel the *menu* window, as I can
only find two codes that do dismiss the wxDialog(wxID_OK and wxID_CANCEL).

Help appreciated,
BenG.

···

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

You need to connect the event of the third button to a function which
calls the EndModal(<retval>) function on the dialog.

EVT_BUTTON(ID_miniframe_CANCEL, NoFunc)

def NoFunc(a_Event):
  dialog.EndModal(<somevalue>)

···

On Thu, 2002-10-10 at 23:11, Ben Gerblich wrote:

Hi All,
I have a GUI containing a canvas(wxScrolledWindow) with many shapes on
it. I want to right click on a shape and produce some kind of *menu* with
a choice of three items (help, properties and close).
Using wxDialog, wxFrame and wxMiniFrame, and after pressing one of the
buttons on my *menu*, all seem to only return two codes, namely wxID_OK
and wxID_CANCEL. I need three return codes to be able to determine which
button was pressed.
Additionally, I need the *menu* window to be MODAL, which means that when
the menu is displayed, the GUI waits until one of the three buttons are
depressed.
Can someone please tell me if there is a more suitable CLASS to use than
those listed above, or tell me if any of the above classes return more
than just the two codes listed above.
---<snip>---
ID_miniFrame_HELP = wxID_OK #<-- pressing a button with these
ID_miniFrame_PARAM = wxID_CANCEL #<-- ID's closes the dialog and
ID_miniFrame_CANCEL= wxID_NO allows me to tell which button
                                         was pressed (see below)
<...>

win = wxDialog(self, -1, "Select an option:", (-1,-1), (-1,-1) )

wxButton(win, ID_miniFrame_HELP, "A", wxPoint( 6, 10), wxSize(150,30) )
wxButton(win, ID_miniFrame_PARAM, "B", wxPoint( 6, 50), wxSize(150,30) )
wxButton(win, ID_miniFrame_CANCEL, "C", wxPoint( 6, 90), wxSize(150,30) )

val = win.ShowModal()

if val == ID_miniFrame_HELP:
    self.displayHelp(shapeUnderMouse)
elif val == ID_miniFrame_PARAM:
    print 'do params'

---<snip>---
In the above code, pressing the HELP and PARAM buttons dismiss the *menu*
window. The CANCEL button does not cancel the *menu* window, as I can
only find two codes that do dismiss the wxDialog(wxID_OK and wxID_CANCEL).

Help appreciated,
BenG.

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
Anthony Tuininga
anthony@computronix.com

Computronix
Distinctive Software. Real People.
Suite 200, 10216 - 124 Street NW
Edmonton, AB, Canada T5N 4A3
Phone: (780) 454-3700
Fax: (780) 454-3838

Ben Gerblich wrote:

Hi All,
I have a GUI containing a canvas(wxScrolledWindow) with many shapes on
it. I want to right click on a shape and produce some kind of *menu* with
a choice of three items (help, properties and close).

How about

  self.PopupMenu(menu, pos)

?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!