diff --git a/plug_py/plug.py b/plug_py/plug.py
index ceb1eb8..3ad383a 100644
--- a/plug_py/plug.py
+++ b/plug_py/plug.py
@@ -72,7 +72,8 @@ def __init__(self, parent=None):
self.ui.startButton.clicked.connect(self.connectWS)
self.ui.selectButton.clicked.connect(self.getMaxSeconds)
self.ui.acceptPriceButton.clicked.connect(self.acceptPrice)
- self.ui.disconnectButton.clicked.connect(self.rejectPrice)
+ self.ui.rejectButton.clicked.connect(self.rejectPrice)
+ self.ui.disconnectButton.clicked.connect(self.disconnect)
self.ui.pcClosedButton.clicked.connect(self.resetToStart)
itemHeight = self.ui.hourList.height()/5
@@ -213,11 +214,26 @@ def resetToStart(self):
self.ui.pcClosedButton.setVisible(False)
self.ui.startButton.setVisible(True)
+ def disconnect(self):
+ self.ws_thread.paymentState = State.closed
+
def closeEvent(self, event):
# cleanup and end threads
- self.terminateThread('node_thread')
- self.terminateThread('ws_thread')
- self.terminateThread('cm_thread')
+ try:
+ self.node_thread.threadActive = False
+ self.node_thread.wait()
+ except:
+ pass
+ try:
+ self.ws_thread.threadActive = False
+ self.ws_thread.wait()
+ except:
+ pass
+ try:
+ self.cm_thread.threadActive = False
+ self.cm_thread.wait()
+ except:
+ pass
# GPIO.cleanup()
event.accept() # let the window close
diff --git a/plug_py/qt/mainwindow.ui b/plug_py/qt/mainwindow.ui
index e44afe9..adde0a0 100644
--- a/plug_py/qt/mainwindow.ui
+++ b/plug_py/qt/mainwindow.ui
@@ -133,7 +133,7 @@ Smart Socket
TextLabel
", None, -1)) self.hourLabel.setText(QtWidgets.QApplication.translate( @@ -129,3 +134,5 @@ def retranslateUi(self, MainWindow): "MainWindow", "