Hi,
Allow me to add some comments from an end user perspective.
From the migration guide - binding events:
All of the EVT_* functions are now instances of the wx.PyEventBinder
class. They have a __call__ method so they can still be used as
functions like before, but making them instances adds some
flexibility.
wx.EvtHandler (the base class for wx.Window) now has a Bind method
that ...
Fact: there is a new and clever way to bind events to an object.
From the migration guide - wx namespace:
You shouldn't need to migrate all your modules over to use the new
package and names right away as there are modules in place that try to
provide as much backwards compatibility of the names as possible. If
you rewrote the above sample using "from wxPython.wx import *", the
old wxNames, and the old style of event binding it will still work
just fine.
Fact: the old style event binding will still work
I really wonder if this is a good idea to keep this backward compatibility.
You know what will happen, some users will keep the old style and
other users will enjoy to use the new form The result is just two
programming styles for the same job. This will only introduce
confusion for new users. Experienced users, who want to exchange
code, will suffer from this too. User A, a new-style programmer, get
code from user B, an old-style programmer. What will the user A do?
i) he/she can keep the code from B and he/she has now a mixture of old and
new styles, what is in my mind not very elegant.
ii) he/she rewrites the code from B and introduced the new style.
iii) he/she rewrites the code from B and reintroduced the old style
(worst case).
Keeping backward compatibility may be nice, but it also has its drawback.
wxPy 2.5 is so new, I wonder if it not better to clean up the situation
even if it breaks compatibility. In that case, forcing the use of the Bind
method.
Beside this Python 2.3 has already introduced enough backward
incompatibilites (deprecation warnings), that a forced change in 2.5
is not so dramatic.
As an example, I can take the small application from the migration
guide and write it in three variants, all doing the same job.
···
----
Variant A (from migration guide)
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
p = wx.Panel(self, -1)
b = wx.Button(p, -1, "Do It", (10,10))
b.Bind(wx.EVT_BUTTON) , self.JustDoIt)
def JustDoIt(self, evt):
print "It's done!"
app = wx.PySimpleApp()
f = MyFrame(None, "What's up?")
f.Show()
app.MainLoop()
----
Variant B
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
p = wx.Panel(self, -1)
b = wx.Button(p, 1001, "Do It", (10,10)) *****
w.EVT_BUTTON(self, 1001, self.JustDoIt) *****
def JustDoIt(self, evt):
print "It's done!"
----
Variant C
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
p = wx.Panel(self, -1)
b = wx.Button(p, -1, "Do It", (10,10)) ******
b.Bind(wx.EVT_BUTTON) , self.JustDoIt) ******
self.JustDoIt(self, evt):
print "It's done!"
If I understand correcty, a clean (==pure wxPy 2.5.xxxx) code uses only
the wx directory. The wxPython dir can be removed.
Last minute remark. I do not know if somebody has tried py2exe. I have.
Seems to work fine.
Jean-Michel Fauth, Switzerland