Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Gui(QtCore.QObject, object): # This is class A that is instanced elsewhere
- capture = cv2.cv.CaptureFromCAM(-1) # Capturing webcam image
- mySignal = QtCore.SIGNAL('mySignal(str)')
- def __init__(self, name=None, parent_node=None, **kwd):
- QtCore.QObject.__init__(self)
- def init_handler(self, **kwd): # The initial declarations go here
- self.gui=guiThread(self)
- self.gui.start()
- def compute_handler(self): # This is the loop that will keep executing periodically
- window = self.gui.window # This window is the gui created in QtDesigner
- self.tempimage = cv2.cv.QueryFrame(self.capture)
- print "about to emit"
- self.emit(QtCore.SIGNAL('mySignal'),"Hello World")
- print "emitted"
- class guiThread(Thread, QtCore.QObject, object):
- def __init__ (self, creator):
- QtCore.QObject.__init__(self)
- self._creator = creator # And now self._creator is the creator object
- Thread.__init__(self)
- self.app = None
- self.window = None
- def run(self):
- self.app = QtGui.QApplication(sys.argv)
- self.window = MainWindow()
- self.window.show()
- print "about to connect"
- self.connect(self._creator, QtCore.SIGNAL('mySignal'),self.printSuccess)
- print "passed the connect"
- self.app.exec_()
- def printSuccess(self, var):
- print "received", var
- def stop(self):
- self.window.close()
- ______________ OUTPUT ______________
- about to connect
- passed the connect
- about to emit
- emitted
- about to emit
- emitted
- about to emit
- emitted
- about to emit
- emitted
- about to emit
- emitted
- .....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement