i have 3 python Files:
file including Many class any methods for initializing Frame and other GUI using pyQt.
file including leap Motion Listener class that read data from leap motion.
Main file that used to start other classes.
now i want to start the GUI frame and the Leap Motion class together. i tried to start two thread in the main class but there is many problems.
this code is valid to run only the pyQt frame :
import sys
from PyQt4 import QtCore, QtGui
from Painter import GUI_animate
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = GUI_animate()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
and this is what i tried to do to run the pyQt frame and Leap Motion class :
import sys
from PyQt4 import QtCore, QtGui
from Painter import GUI_animate
import LeapMotion
from threading import Thread
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
t1 = Thread(target=show_frame())
t2 = Thread(target=start_LeapMotion())
t1.start()
t2.start()
self.ui.setupUi(self)
def start_LeapMotion():
LeapMotion.main()
def show_frame():
StartQT4.ui = GUI_animate()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
but only Leap Motion class run, and after finish reading from leap motion, the frame show !
how can i run them together?