- in CNCJob UI Autolevelling - GRBL Control and Sender tabs are disabled when the serial port is disconnected

This commit is contained in:
Marius Stanciu
2020-08-19 04:44:50 +03:00
parent 7285ee0b82
commit d62793c9bd
3 changed files with 23 additions and 5 deletions

View File

@@ -954,9 +954,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.app.inform.emit("%s: %s" % (_("Port connected"), port_name))
self.ui.com_connect_button.setStyleSheet("QPushButton {background-color: seagreen;}")
self.ui.com_connect_button.setText(_("Connected"))
for idx in range(self.ui.al_toolbar.count()):
if self.ui.al_toolbar.tabText(idx) == _("Connect"):
self.ui.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('seagreen'))
if self.ui.al_toolbar.tabText(idx) == _("Control"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, True)
if self.ui.al_toolbar.tabText(idx) == _("Sender"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, True)
# Toggle DTR to reset the controller loaded with GRBL (Arduino, ESP32, etc)
try:
self.grbl_ser_port.dtr = False
@@ -974,9 +980,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.grbl_ser_port.port = port_name
self.grbl_ser_port.close()
self.ui.com_connect_button.setStyleSheet("QPushButton {background-color: red;}")
self.ui.com_connect_button.setText(_("Disconnected"))
for idx in range(self.ui.al_toolbar.count()):
if self.ui.al_toolbar.tabText(idx) == _("Connect"):
self.ui.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
if self.ui.al_toolbar.tabText(idx) == _("Control"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, False)
if self.ui.al_toolbar.tabText(idx) == _("Sender"):
self.ui.al_toolbar.tabBar.setTabEnabled(idx, False)
self.app.inform.emit("%s: %s" % (_("Port is connected. Disconnecting"), port_name))
except Exception:
self.app.inform.emit("[ERROR_NOTCL] %s: %s" % (_("Could not connect to port"), port_name))