Handling Dialog Events

Hard to get the complete picture from your text but:

in place of >>> EVT_BUTTON(self, D_ONAUTO_CONFIG, self.GetStatusOffset)
try >>> EVT_BUTTON(setup, ID_ONAUTO_CONFIG, self.GetStatusOffset)

I.e. the event is originating from the dialog object, not the main
frame. AFAIK Although a button-click generates a wxCommandEvent which
should propagate up the object hierarchy, events generated within
dialogs do not propagate beyond their top-level wxDialog object.

HTH
Bryan

···

On Fri, 2003-01-31 at 14:47, Christian Wyglendowski wrote:

Hi,

Well, here is my first question to the members of this list.

I am writing a small notifiation application for Windows that runs in the system tray. I want to catch an EVT_BUTTON event from a setup dialog box, but I can't seem to get the program to handle it. I have defined a popupmenu for my tray icon that responds to an EVT_TASKBAR_RIGHT_UP event. From here, one of the options on the menu is a setup dialog. Here is some example code from that dialog:

    def OnSetup(self, evt):
        setup = wxDialog(self, -1, 'Setup', size = (300, 200),
                             style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME)
        ##begin first row in dialog
        sizer = wxBoxSizer(wxVERTICAL)
        box = wxBoxSizer(wxHORIZONTAL)
        button = wxButton(setup, ID_ONAUTO_CONFIG, 'AutoConfig') #create the button in question
        box.Add(button, 0, wxALIGN_CENTER|wxALL, 5)

        sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)

        ...code for other controls omitted (wxTextCtrl, Ok and Cancel buttons)....
        
        setup.SetSizer(sizer)
        setup.SetAutoLayout(true)
        sizer.Fit(setup)
        
        val = setup.ShowModal()
        if val == wxID_OK:
                ...code to handle when the OK button is pressed omitted...
        else:
            pass # Cancel was pressed

Handling the OK and CANCEL buttons was easy (though maybe there is a better way). I have setup an EVT_BUTTON(self, ID_ONAUTO_CONFIG, self.GetStatusOffset) event handler in the __init__() method of my main frame.

Am I missing something? Do I need to create a class instance of wxDialog and have it handle the button event? It seems like my wxFrame instance should be able to handle it. If I didn't provide enough code, let me know.

Thanks,

Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382