Created
April 16, 2014 19:18
-
-
Save ivanalejandro0/10922674 to your computer and use it in GitHub Desktop.
Signaling test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
from PySide import QtCore, QtGui | |
class Foo(QtGui.QWidget): | |
some_signal_1 = QtCore.Signal(str) | |
some_signal_2 = QtCore.Signal(list) | |
def __init__(self): | |
QtGui.QWidget.__init__(self) | |
self.some_signal_1.connect(self.some_slot_1) | |
self.some_signal_1.connect(self.some_slot_2) | |
self.some_signal_1.connect(self.some_slot_3) | |
self.some_signal_1.connect(self.some_slot_4) | |
self.some_signal_2.connect(self.some_slot_a) | |
@QtCore.Slot(str) | |
def some_slot_1(self, data): | |
print "Slot 1 - data: {0} - type(data): {1}".format(data, type(data)) | |
@QtCore.Slot(float) | |
def some_slot_2(self, data): | |
print "Slot 2 - data: {0} - type(data): {1}".format(data, type(data)) | |
@QtCore.Slot(int) | |
def some_slot_3(self, data): | |
print "Slot 2 - data: {0} - type(data): {1}".format(data, type(data)) | |
@QtCore.Slot(list) | |
def some_slot_4(self, data): | |
print "Slot 4 - data: {0} - type(data): {1}".format(data, type(data)) | |
@QtCore.Slot(str) | |
def some_slot_a(self, data): | |
print "Slot a - data: {0} - type(data): {1}".format(data, type(data)) | |
def something(self): | |
self.some_signal_1.emit('blah') | |
self.some_signal_1.emit(['a', 12, 'b']) | |
self.some_signal_2.emit(42) | |
if __name__ == '__main__': | |
app = QtGui.QApplication(sys.argv) | |
foo = Foo() | |
foo.something() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: