sending arguments on button callback

I have a button to which I have attached a callback. I am getting an error:

TypeErrorL ClearandReset() takes exactly 1 argument (2 given)

The code is as follows:

       self.clearbutton = wxButton(self, 33, label= "Read and Clear Status",
                            style = wxBU_BOTTOM ,size=wxDefaultSize,
                            name = "ClearandReset")
       EVT_BUTTON(self, 33, self.ClearandReset)

and

       def ClearandReset(self):

Can someone explain to me where I am passing two arguments?

--vicki

Hi Vicki,

you have to define:
def ClearandReset(self,event):
...

···

At 09:47 12.08.2003 -0500, you wrote:

I have a button to which I have attached a callback. I am getting an error:

TypeErrorL ClearandReset() takes exactly 1 argument (2 given)

The code is as follows:

       self.clearbutton = wxButton(self, 33, label= "Read and Clear Status",
                            style = wxBU_BOTTOM ,size=wxDefaultSize,
                            name = "ClearandReset")
       EVT_BUTTON(self, 33, self.ClearandReset)

and

       def ClearandReset(self):

Can someone explain to me where I am passing two arguments?

--vicki

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

       def ClearandReset(self):

Try:

def ClearandReset( self, event ):

hope that helps

Przemek

···

--
Przemyslaw G. Gawronski
Informatyk w Sekcji Systemu, Telemetria
TNS OBOP
ul.Dereniowa 11
02-776 Warszawa
e przemyslaw.gawronski@tns-global.pl
t +48 22 648 20 44 (-46)
f +48 22 644 9947
http://www.tns-global.pl

EVT_BUTTON callbacks (and most event callbacks, IIRC) receive an event parameter in addition to self. This isn't something you set up, it's just the way the wxWindows toolkit is constructed. Your callback should be defined as:

def ClearandReset(self, event):

The event parameter is an event object instance which provides information about the event that may or may not be interesting to you. This can include the id of the widget that generated the event, what type of event, what mouse buttons were used, etc.

Nathan R. Yergler

Vicki Stanfield wrote:

···

I have a button to which I have attached a callback. I am getting an error:

TypeErrorL ClearandReset() takes exactly 1 argument (2 given)

The code is as follows:

      self.clearbutton = wxButton(self, 33, label= "Read and Clear Status",
                           style = wxBU_BOTTOM ,size=wxDefaultSize,
                           name = "ClearandReset")
      EVT_BUTTON(self, 33, self.ClearandReset)

and

      def ClearandReset(self):

Can someone explain to me where I am passing two arguments?

--vicki

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