[PyQt] Overloading new-style signal
Knacktus
knacktus at googlemail.com
Sat Feb 19 16:56:35 GMT 2011
Hi guys,
I don't get overloading of new-style signals to work. I can't spot the
mistake ... my eyes don't see anything anymore ;-).
Any help is highly appreciated.
Cheers,
Jan
Here's an example:
import PyQt4.Qt as Qt
import PyQt4.QtCore as QtCore
class ItemsChangedNotifier(Qt.QObject):
items_changed = QtCore.pyqtSignal([list], [dict])
class ItemChanger(object):
def __init__(self):
self.notifier = ItemsChangedNotifier()
def change_with_list(self, items):
self.notifier.items_changed.emit(items)
def change_with_dict(self, old_items_to_new_items):
self.notifier.items_changed[dict].emit(old_items_to_new_items)
class Presenter(object):
def __init__(self, item_changer):
self.item_changer = item_changer
self.item_changer.notifier.items_changed.connect(self.show_list)
self.item_changer.notifier.items_changed[dict].connect(self.show_dict)
def show_list(self, items):
print "list %s" % items
def show_dict(self, old_items_to_new_items):
print "dict %s" % old_items_to_new_items
if __name__ == "__main__":
changer = ItemChanger()
presenter = Presenter(changer)
changer.change_with_list(["Check", 1, 2, 3])
changer.change_with_dict({"old": "new"})
More information about the PyQt
mailing list