Getting object name after an event occurred

Jorge Godoy wrote:

> http://www.wxwindows.org/manuals/2.5.1/wx_wxevent.html#topic336
> event.GetEventObject() should do it.

I had already tried that. Is there any way to get the object's name, as I
asked? I printed the output from an 'OK' button clicked:

What do you mean by "the object's name"? If you mean the name of a variable
that references the object, then no, you can't. (The long answer is that
you prbably can with efforts in limited cases, but it's a really bad idea.)

<wxPython.controls.wxButton instance; proxy of C++ wxButton instance at
_845f020_wxButton_p>

Can't you use a method of this object to see if it was the OK button?
Something like: event.GetEventObject().GetLabel() perhaps?

···

On Ter 04 Mai 2004 02:54, Peter Damoc wrote:

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

Magnus Lycka wrote:

Jorge Godoy wrote:

http://www.wxwindows.org/manuals/2.5.1/wx_wxevent.html#topic336
event.GetEventObject() should do it.

I had already tried that. Is there any way to get the object's name, as I
asked? I printed the output from an 'OK' button clicked:

What do you mean by "the object's name"? If you mean the name of a variable
that references the object, then no, you can't. (The long answer is that
you prbably can with efforts in limited cases, but it's a really bad idea.)

<wxPython.controls.wxButton instance; proxy of C++ wxButton instance at
_845f020_wxButton_p>

Can't you use a method of this object to see if it was the OK button? Something like: event.GetEventObject().GetLabel() perhaps?

Or:

  if event.GetId() == self.self.choiceCodGrupo.GetId():
    ...

or even:

  if event.GetEventObject() is self.choiceCodGrupo:
    ...

···

On Ter 04 Mai 2004 02:54, Peter Damoc wrote:

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

Two things:

First I think I misread Magnus answer, sorry Magnus.

Second I liked more the second option above, from Robin. Much better than I
was doing. :slight_smile:

Thanks!

···

On Ter 04 Mai 2004 14:26, Robin Dunn wrote:

Or:

if event.GetId() == self.self.choiceCodGrupo.GetId():
...

or even:

if event.GetEventObject() is self.choiceCodGrupo:
...

--
Godoy. <godoy@ieee.org>