- provide loop at ws::connect
This commit is contained in:
+9
-3
@@ -5,7 +5,7 @@ from ws.client.ws_client import WsClient
|
||||
from ws.message import MessageDispatcher
|
||||
|
||||
|
||||
class Window(QtWidgets.QMainWindow):
|
||||
class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def __init__(self):
|
||||
QtWidgets.QMainWindow.__init__(self)
|
||||
self.msg_dispatch = MessageDispatcher()
|
||||
@@ -18,8 +18,16 @@ class Window(QtWidgets.QMainWindow):
|
||||
self.msg_sensor.set_recv_handler(self.on_sensor_changed)
|
||||
self.msg_heater.set_recv_handler(self.on_heater_changed)
|
||||
|
||||
self.setupUi(self)
|
||||
self.actionStart.triggered.connect(self.connect)
|
||||
self.actionStop.triggered.connect(self.disconnect)
|
||||
|
||||
def connect(self):
|
||||
self.ws_client.connect(uri="ws://localhost:8765")
|
||||
|
||||
def disconnect(self):
|
||||
self.ws_client.disconnect()
|
||||
|
||||
def on_pot_changed(self, msg):
|
||||
print("on_pot_changed")
|
||||
|
||||
@@ -51,8 +59,6 @@ class Window(QtWidgets.QMainWindow):
|
||||
if __name__ == '__main__':
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
win = Window()
|
||||
ui = Ui_MainWindow()
|
||||
ui.setupUi(win)
|
||||
win.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user