63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
def main():
|
|
global threading
|
|
import threading
|
|
global queue
|
|
import queue
|
|
global qtpy
|
|
import qtpy
|
|
|
|
global QApplication
|
|
from qtpy.QtWidgets import QApplication
|
|
global QtCore
|
|
import qtpy.QtCore as QtCore
|
|
global QThread
|
|
from qtpy.QtCore import QThread
|
|
global QObject
|
|
from qtpy.QtCore import QObject
|
|
|
|
global oxiQtQueue
|
|
oxiQtQueue = queue.Queue()
|
|
|
|
class qtThread(QThread):
|
|
#qt5:
|
|
cmd = QtCore.Signal(list)
|
|
|
|
def __init__(self,*args,**kwargs):
|
|
super().__init__(*args,**kwargs)
|
|
|
|
def run(self):
|
|
while True:
|
|
cmd = oxiQtQueue.get()
|
|
#qt4:
|
|
#self.emit(QtCore.SIGNAL("cmd"),cmd)
|
|
|
|
#qt5:
|
|
self.cmd.emit(cmd)
|
|
|
|
class qtApp(QApplication):
|
|
def __init__(self,readyQueue,*args,**kwargs):
|
|
super().__init__(*args,**kwargs)
|
|
self.queueThread = qtThread()
|
|
#qt4:
|
|
#self.queueThread.connect(self.queueThread,QtCore.SIGNAL("cmd"),self.queueCallback)
|
|
|
|
#qt5:
|
|
self.queueThread.cmd.connect(self.queueCallback)
|
|
|
|
self.queueThread.start()
|
|
readyQueue.put(True)
|
|
|
|
def queueCallback(self,cmd):
|
|
cmd[0](*cmd[1],**cmd[2])
|
|
|
|
def close(self):
|
|
self.quit()
|
|
|
|
readyQueue = queue.Queue()
|
|
global oxiQtApp
|
|
oxiQtApp = qtApp(readyQueue,sys.argv)
|
|
global oxiMainThreadQueue
|
|
oxiMainThreadQueue.put([oxiQtApp.exec_,[],{}])
|
|
readyQueue.get()
|
|
print("Qt app running")
|
|
main() |