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