[Tutor] Reuse of callback

Vicki Stanfield vicki at thepenguin.org
Fri Dec 12 13:15:14 EST 2003


I have a function which is called via a button callback. I would like to
reuse this function based on the setting of a radio box button. The
existing function is like this:

    def Pass2ME(self,event):
        something()

and it is called by this:

    self.pass2mebutton = wxButton(self, 32, label= "Pass to ME",
                            style = wxBU_BOTTOM ,size=(150,20),
                            name = "Pass2ME")
    EVT_BUTTON(self, 32, self.Pass2ME)


now I want to call the same Pass2ME function from a toggle button if the
setting is ME. I have the code to create the radio box coded like this:

    self.MyController=wxRadioBox(self, 35, majorDimension = 1,
                                      choices=['UI','ME'],
                                      style= wxSUNKEN_BORDER |
                                      wxALIGN_BOTTOM|wxRB_SINGLE)
    EVT_RADIOBOX(self, 35, self.SetMyController)


self.SetMyController looks like this:

    def SetMyController(self,event):
        if event.GetString() == 'ME':
            Pass2ME(self, event)
        else:
            somethingelse()


I am getting an error due to the number of parameters passed to the
Pass2ME function.

The error is:

Traceback (most recent call last):
  File "F:\wxComTool9.5.py", line 2109, in ?
    frame=MyFrame(NULL, -1, "Communication Tool")
  File "F:\wxComTool9.5.py", line 2083, in __init__
    panel1 = ComboBoxPanel(self,-1, wxDefaultSize, style=wxSUNKEN_BORDER)
  File "F:\wxComTool9.5.py", line 98, in __init__
    style= wxSUNKEN_BORDER | wxALIGN_BOTTOM|wxRB_SINGLE)
  File "C:\Python23\Lib\site-packages\wxPython\controls.py", line 969, in
__init
__
    self.this = controlsc.new_wxRadioBox(*_args,**_kwargs)
TypeError: new_wxRadioBox() takes at least 3 arguments (2 given)
13:18:13: Debug: e:\Projects\wx2.4\src\msw\app.cpp(439):
'UnregisterClass(canvas
)' failed with error 0x00000584 (class still has open windows.).

Any help is greatly appreciated.

--vicki



More information about the Tutor mailing list