Lock connection details while connecting

Fix connect button behaviour
This commit is contained in:
atse 2023-07-07 16:31:47 +08:00 committed by Tse Kwok Yan
parent 3b0c630d43
commit 8cf0f2c0be
1 changed files with 7 additions and 0 deletions

View File

@ -148,8 +148,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
try:
if self.tec_client is None:
self.status_lbl.setText("Connecting...")
self.ip_set_line.setEnabled(False)
self.port_set_spin.setEnabled(False)
self.connect_btn.setEnabled(False)
self.tec_client = Client()
await self.tec_client.connect(host=ip, port=port, timeout=30)
self.connect_btn.setEnabled(True)
self._on_connection_changed(True)
self._hw_rev(await self.tec_client.hw_rev())
self.fan_update(await self.tec_client.fan())
@ -171,6 +177,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
except Exception as e:
logging.error(f"Failed communicating to the {ip}:{port}: {e}")
self._on_connection_changed(False)
self.connect_btn.setEnabled(True)
async def coro_main():