conneting

This commit is contained in:
atse 2024-08-22 17:11:56 +08:00
parent fcadb8aa44
commit f887413d82

View File

@ -239,17 +239,19 @@ class MainWindow(QtWidgets.QMainWindow):
except: except:
pass pass
@asyncSlot() def _connecting(self):
async def on_connect_btn_clicked(self):
if (self._connecting_task is None) and (not self.thermostat.connected()):
self.status_lbl.setText("Connecting...") self.status_lbl.setText("Connecting...")
self.connect_btn.setText("Stop") self.connect_btn.setText("Stop")
self.conn_menu.host_set_line.setEnabled(False) self.conn_menu.host_set_line.setEnabled(False)
self.conn_menu.port_set_spin.setEnabled(False) self.conn_menu.port_set_spin.setEnabled(False)
@asyncSlot()
async def on_connect_btn_clicked(self):
if (self._connecting_task is None) and (not self.thermostat.connected()):
host = self.conn_menu.host_set_line.text() host = self.conn_menu.host_set_line.text()
port = self.conn_menu.port_set_spin.value() port = self.conn_menu.port_set_spin.value()
self._connecting()
self._connecting_task = asyncio.create_task( self._connecting_task = asyncio.create_task(
self.thermostat.start_session(host=host, port=port) self.thermostat.start_session(host=host, port=port)
) )