Hi Jorgen,
the main issue is that the QT's SigSlot is how Trolltech sees the event
handling issue
In wxPython the event handling is done by binging events tho event handlers
as you can see in various tutorials in the wiki
If you are keen on using something like SigSlot I guess you could
implement it yourself, is not very hard you could either decorate or even
ducktape the wxPython classes to provide this functionality.
You could take a look at wax it uses something like a midway between
wxpython and sigslot
Here is a small example on how I see the SigSlot approach:
import wx
class Signal:
_slots = []
def connect(self, slot):
self._slots.append(slot)
def disconnect(self, slot):
if slot in self._slots:
self.slots.remove(slot)
def submit(self, *args):
for slot in self._slots:
slot(*args)
class EventSignal(Signal):
def __init__(self, widget, event):
widget.Bind(event, self.decode_submit)
def decode_submit(self, evt):
'''here, in theory, you could decode the event and call the slots
with something more relevant
'''
self.submit(evt)
class CustomFrame(wx.Frame):
def __init__(self):
wx.Frameinit__(self, None, title="TestFrame")
button = wx.Button(self, label="Push Me")
v = 1
if v == 1:
''' binding 2 methods to a single event will cause only the last
one to be called'''
button.Bind(wx.EVT_BUTTN, Button1)
button.Bind(wx.EVT_BUTTN, Button2)
elif v == 2:
''' You can use custom Signal clasess '''
self.pressButtonSignal = EventSignal(button, wx.EVT_BUTTN)
self.pressButtonSignal.connect(Button1)
self.pressButtonSignal.connect(Button2)
elif v ==3:
''' or you can use Generic clasess '''
self.pressButtonSignal = Signal()
button.Bind(wx.EVT_BUTTN, self.pressButtonSignal.submit)
self.pressButtonSignal.connect(Button1)
self.pressButtonSignal.connect(Button2)
def Button1(self, evt):
print "Button1"
def Button2(self, evt):
print "Button2"
if __name__ == "__main__":
app = wx.App(0)
frame = CustomFrame()
frame.Show()
app.MainLoop()