1
0
Fork 0

disable some elements

This commit is contained in:
Peter McGoron 2021-05-27 21:39:41 -04:00
parent fc3f677116
commit 1a2a5d8483
1 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,8 @@ import serial
import serial.tools.list_ports
import re
CHANGE_BUTTONS = ["SET_do", "RAMP_do", "sel_ref", "sel_do"]
def error_popup(parent, msg):
box = Gtk.MessageDialog(
parent=parent,
@ -25,7 +27,9 @@ class SerComm:
s = self.ser.read_until().decode()
if not s:
raise Exception(f"DAC timeout: '{s}'")
return s.rstrip("\r\n")
s = s.rstrip("\r\n")
self.getobj("dac_resp").set_text(s)
return s
def connect(self):
s = self.sel_box.get_active_id()
@ -53,10 +57,16 @@ class SerComm:
self.getobj("dac_idn").set_label(self.get_or_to())
def on_connect(self, _):
for x in CHANGE_BUTTONS:
self.getobj(x).set_sensitive(False)
try:
self.connect()
except Exception as e:
self.error_popup(str(e))
self.error_popup(str(e))
for x in CHANGE_BUTTONS:
self.getobj(x).set_sensitive(True)
def refresh(self, _):
# Does this cause a memory error? This is a GTK interned string