-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (33 loc) · 1.05 KB
/
main.py
File metadata and controls
44 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView
from PyQt5.QtQml import QJSValue
class IceController(QObject):
def __init__(self):
QObject.__init__(self)
self.callback = []
def dump(self):
print("Dump was called")
for c in self.callback:
c.call([QJSValue("Data from Python")])
self.callback[:] = []
@pyqtSlot(str, "QJSValue")
def enqueue(self, command, callback):
print("Enqueuing function of %s" % command)
self.callback.append(QJSValue(callback))
@pyqtSlot()
def processResponses(self):
print("processing responses")
self.dump()
@pyqtSlot(str)
def log(self, s):
print(s)
print("Starting ICE Control GUI...")
app = QApplication(sys.argv)
view = QQuickView()
context = view.rootContext()
ice = IceController()
context.setContextProperty("PyConsole", ice)
context.setContextProperty("ice", ice)
view.setSource(QUrl("main.qml"))