What happened to wxEVT_COMMAND_BUTTON_CLICKED?

Hello all,

I am upgrading a bunch of classes to the most recent version of wxPython. Basically, these are widgets that can be programmatically activated. I use them to write wxPython GUIs which can tested automatically.

For example, I have a button that can click itself. It looks like this:

···

----
from wxPython.wx import *

class wxButtonWithHelpers(wxButton):
    """A wxButton with methods for simulating user actions on it.
    """
    def __init__(self, parent, ID, Caption, position, size):
        wxButton.__init__(self, parent, ID, Caption, position, size)
    
    def Click(self):
        click_event = wxCommandEvent(wxEVT_COMMAND_BUTTON_CLICKED, self.GetId())
        self.ProcessEvent(click_event)
----

As far as the application goes, invoking the Click() method of a button is exactly the same as if the end user had actually clicked on it.

When I run this under the newer version of wxPython, I get:

---
DeprecationWarning: The wxPython compatibility package is no longer automatically generated or activly maintained. Please switch to the wx package as soon as possible.
---

So I changed it to this:

----
import wx

class wxButtonWithHelpers(wx.Button):
    """A wxButton with methods for simulating user actions on it.
    """
    def __init__(self, parent, ID, Caption, position, size):
        wx.Button.__init__(self, parent, ID, Caption, position, size)
    
    def Click(self):
        click_event = wx.CommandEvent(wx.EVT_COMMAND_BUTTON_CLICKED, self.GetId())
        self.ProcessEvent(click_event)
----

And now I get this:

----
AttributeError: 'module' object has no attribute 'EVT_COMMAND_BUTTON_CLICKED'
----

I tried leaving it as wxEVT_COMMAND_BUTTON_CLICKED, but I get:

----
NameError: global name 'wxEVT_COMMAND_BUTTON_CLICKED' is not defined
----

So... In the new version of wxPython, what is the equivalent of wxEVT_COMMAND_BUTTON_CLICKED?

Thx.

----
Alain Désilets, MASc
Agent de recherches/Research Officer
Institut de technologie de l'information du CNRC /
NRC Institute for Information Technology

alain.desilets@nrc-cnrc.gc.ca
Tél/Tel (613) 990-2813
Facsimile/télécopieur: (613) 952-7151

Conseil national de recherches Canada, M50, 1200 chemin Montréal,
Ottawa (Ontario) K1A 0R6
National Research Council Canada, M50, 1200 Montreal Rd., Ottawa, ON
K1A 0R6

Gouvernement du Canada | Government of Canada

HI Alain,

AttributeError: 'module' object has no attribute
'EVT_COMMAND_BUTTON_CLICKED'
----

I tried leaving it as wxEVT_COMMAND_BUTTON_CLICKED, but I get:

----
NameError: global name 'wxEVT_COMMAND_BUTTON_CLICKED' is not defined
----

So... In the new version of wxPython, what is the equivalent
of wxEVT_COMMAND_BUTTON_CLICKED?

Try this:

wx.wxEVT_COMMAND_BUTTON_CLICKED

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Thx. It worked.

···

-----Original Message-----
From: Gavana, Andrea [mailto:gavana@kpo.kz]
Sent: January 11, 2007 12:45 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] What happened to
wxEVT_COMMAND_BUTTON_CLICKED?

HI Alain,

> AttributeError: 'module' object has no attribute
> 'EVT_COMMAND_BUTTON_CLICKED'
> ----
>
> I tried leaving it as wxEVT_COMMAND_BUTTON_CLICKED, but I get:
>
> ----
> NameError: global name 'wxEVT_COMMAND_BUTTON_CLICKED' is not defined
> ----
>
> So... In the new version of wxPython, what is the equivalent of
> wxEVT_COMMAND_BUTTON_CLICKED?

Try this:

wx.wxEVT_COMMAND_BUTTON_CLICKED

Andrea.

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

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

Just for your interest, if you import wx, most of the event types
can be access by using wx.wx{EVENTNAME}.

Desilets, Alain schrieb:

···

Thx. It worked.

-----Original Message-----
From: Gavana, Andrea [mailto:gavana@kpo.kz] Sent: January 11, 2007 12:45 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] What happened to wxEVT_COMMAND_BUTTON_CLICKED?

HI Alain,

AttributeError: 'module' object has no attribute 'EVT_COMMAND_BUTTON_CLICKED'
----

I tried leaving it as wxEVT_COMMAND_BUTTON_CLICKED, but I get:

----
NameError: global name 'wxEVT_COMMAND_BUTTON_CLICKED' is not defined
----

So... In the new version of wxPython, what is the equivalent of wxEVT_COMMAND_BUTTON_CLICKED?
      

Try this:

wx.wxEVT_COMMAND_BUTTON_CLICKED

Andrea.

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London
Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

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

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

Just for your interest, if you import wx, most of the event

> types can be access by using wx.wx{EVENTNAME}.

That's not my experience. I find them as wx.EVT_xxx. And that's what
I would expect -- in general, the wxMumble names in regular wxWidgets
shown up as wx.Mumble in wxPython. (Exceptions include the things
that are in submodules, like wx.wizard.)

This name mangling sure is confusing.

     paul

No, Hannes is correct. Event ids (or whatever they are called), can be
generically found using wx.wxWHATEVER, while event *binders* are
accessed via wx.WHATEVER.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

···

On 1/11/07, Paul Koning <pkoning@equallogic.com> wrote:

> Just for your interest, if you import wx, most of the event
> types can be access by using wx.wx{EVENTNAME}.

That's not my experience. I find them as wx.EVT_xxx. And that's what
I would expect -- in general, the wxMumble names in regular wxWidgets
shown up as wx.Mumble in wxPython. (Exceptions include the things
that are in submodules, like wx.wizard.)

Yeah, I've had those problems, too.
The book "wxPython in Action" by Manning covers most of the general
misunderstandings and explains why some things in wxPython are as they are.

Sorry for the typo "access" in my last reply, should've been "accessed".

Paul Koning schrieb:

···

            
> Just for your interest, if you import wx, most of the event
> types can be access by using wx.wx{EVENTNAME}.

That's not my experience. I find them as wx.EVT_xxx. And that's what
I would expect -- in general, the wxMumble names in regular wxWidgets
shown up as wx.Mumble in wxPython. (Exceptions include the things
that are in submodules, like wx.wizard.)

This name mangling sure is confusing.

     paul

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

Desilets, Alain wrote:

Hello all,

I am upgrading a bunch of classes to the most recent version of wxPython. Basically, these are widgets that can be programmatically activated. I use them to write wxPython GUIs which can tested automatically.

For example, I have a button that can click itself. It looks like this:

----
from wxPython.wx import *

class wxButtonWithHelpers(wxButton):
    """A wxButton with methods for simulating user actions on it.
    """
    def __init__(self, parent, ID, Caption, position, size):
        wxButton.__init__(self, parent, ID, Caption, position, size)
        def Click(self):
        click_event = wxCommandEvent(wxEVT_COMMAND_BUTTON_CLICKED, self.GetId())
        self.ProcessEvent(click_event)
----

As far as the application goes, invoking the Click() method of a button is exactly the same as if the end user had actually clicked on it.

When I run this under the newer version of wxPython, I get:

---
DeprecationWarning: The wxPython compatibility package is no longer automatically generated or activly maintained. Please switch to the wx package as soon as possible.
---

So I changed it to this:

----
import wx

class wxButtonWithHelpers(wx.Button):
    """A wxButton with methods for simulating user actions on it.
    """
    def __init__(self, parent, ID, Caption, position, size):
        wx.Button.__init__(self, parent, ID, Caption, position, size)
        def Click(self):
        click_event = wx.CommandEvent(wx.EVT_COMMAND_BUTTON_CLICKED, self.GetId())
        self.ProcessEvent(click_event)
----

And now I get this:

----
AttributeError: 'module' object has no attribute 'EVT_COMMAND_BUTTON_CLICKED'
----

I tried leaving it as wxEVT_COMMAND_BUTTON_CLICKED, but I get:

----
NameError: global name 'wxEVT_COMMAND_BUTTON_CLICKED' is not defined
----

So... In the new version of wxPython, what is the equivalent of wxEVT_COMMAND_BUTTON_CLICKED?

The wxEVT_ names are the exception to the renaming rule. It had to be this way because there were a number of name conflicts between the EVT_ binder names and matching wxEVT_ eventType names, so making both of them be wx.EVT_ names would cause problems.

BTW, in the next release you'll be able to get to the eventType value using the event binder object, so you won't have to find or remember the wx.wxEVT_ names and figure out which ones correspond to which event binder. For example, instead of using wx.wxEVT_COMMAND_BUTTON_CLICKED you would use wx.EVT_BUTTON.typeId.

(You can actually already get at this value in present releases, but not in the way that I want to make public.)

···

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