[wxPython] Multiple buttons in wxDialog

Using wxPython I am unable to get buttons with values other than the wxID_OK
and the wxID_CANCEL to be recognized. When I test for the values I get
values for OK and CANCEL but nothing for BACK and NEXT. Is wxDialog
constrained to OK/CANCEL/APPLY? Is there another control I should use to
create multiple buttons?

    win = wxDialog(None, -1, type + " " + item, wxDefaultPosition,
wxSize(450, 300))
    wxStaticText(win, -1, item + " Type:", wxPoint(10, 10), wxSize(100, 20))
    wxStaticText(win, -1, "Participating Topics:", wxPoint(10, 50),
wxSize(120, 20))
    wxStaticText(win, -1, "Topic:", wxPoint(10, 70), wxSize(50, 20))
    wxStaticText(win, -1, item + " Role Type:", wxPoint(120, 70),
wxSize(150, 20))
    wxStaticText(win, -1, item + " Role:", wxPoint(280, 70), wxSize(150,
20))
    wxButton(win, wxID_OK, " OK ", wxPoint(120, 240),
wxDefaultSize).SetDefault()
    wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(270, 240), wxDefaultSize)
    wxStaticText(win, 100, assocChoice.GetStringSelection(), wxPoint(110,
10), wxSize(200, 20))
    wxButton(win, 90, " Back ", wxPoint(120, 210), wxDefaultSize)
    wxButton(win, 91, " Next ", wxPoint(270, 210), wxDefaultSize)
    val = win.ShowModal()

<!-- ****************************************************************
Eric Freese Email: eric@isogen.com
Director - Professional Services - Midwest Voice: 651 636 9180
ISOGEN International/DataChannel Fax: 651 636 9191
1611 West County Road B - Suite 204 WWW: www.isogen.com
St. Paul, MN 55113 www.datachannel.com
***************************************************************** -->

If I'm understanding the problem correctly, take a look at the demos with
buttons and look for lines like:

  EVT_BUTTON( self, BUTTONID, self.OnSomeButton )

Which are how the button is "recognised" (passes events to a method).
wxID_OK and wxID_CANCEL are special cases that have automagic handling, not
general-case patterns for copying.

HTH,
Mike

···

-----Original Message-----
From: Eric Freese [mailto:eric@isogen.com]
Sent: Friday, April 27, 2001 10:47
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython] Multiple buttons in wxDialog

Using wxPython I am unable to get buttons with values other than the wxID_OK
and the wxID_CANCEL to be recognized. When I test for the values I get
values for OK and CANCEL but nothing for BACK and NEXT. Is wxDialog
constrained to OK/CANCEL/APPLY? Is there another control I should use to
create multiple buttons?
...

If I'm understanding the problem correctly, take a look at the demos with
buttons and look for lines like:

EVT_BUTTON( self, BUTTONID, self.OnSomeButton )

Which are how the button is "recognised" (passes events to a method).
wxID_OK and wxID_CANCEL are special cases that have automagic handling,

not

general-case patterns for copying.

Correct. In fact they are implemented in wxDialog the same way as you would
want to do it yourself for the nonstandard IDs.

If you want your buttons to behave like the others and complete (close) the
dialog and return a specific value from ShowModal then you can use
self.EndModal(ID_TO_RETURN) from within your event handler.

···

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