def __init__(self, prometheus): super(PrometheusGui, self).__init__(None) self.prometheus = prometheus self.setGeometry(300, 300, 250, 150) self.setWindowTitle("Prometheus FX3 Server/Programmer") self.show() #Setup the main horizontal splitter layout = QHBoxLayout() #Setup the 3 status boxes on the left status_layout = QVBoxLayout() self.programmer = PrometheusProgrammer(self.prometheus) self.status = PrometheusStatus(self.prometheus) self.status_server = PrometheusServerStatus(self.prometheus, "Status Server") self.data_server = PrometheusServerStatus(self.prometheus, "Data Server") status_layout.addWidget(self.status) status_layout.addWidget(self.programmer) status_layout.addWidget(self.status_server) status_layout.addWidget(self.data_server) layout.addItem(status_layout) #Setup the main status box self.comm = PrometheusComm(self.prometheus) layout.addWidget(self.comm) self.setLayout(layout) self.status.set_level(0)
class PrometheusGui (QWidget): """ Visual Interface to Prometheus """ def __init__(self, prometheus): super(PrometheusGui, self).__init__(None) self.prometheus = prometheus self.setGeometry(300, 300, 250, 150) self.setWindowTitle("Prometheus FX3 Server/Programmer") self.show() #Setup the main horizontal splitter layout = QHBoxLayout() #Setup the 3 status boxes on the left status_layout = QVBoxLayout() self.programmer = PrometheusProgrammer(self.prometheus) self.status = PrometheusStatus(self.prometheus) self.status_server = PrometheusServerStatus(self.prometheus, "Status Server") self.data_server = PrometheusServerStatus(self.prometheus, "Data Server") status_layout.addWidget(self.status) status_layout.addWidget(self.programmer) status_layout.addWidget(self.status_server) status_layout.addWidget(self.data_server) layout.addItem(status_layout) #Setup the main status box self.comm = PrometheusComm(self.prometheus) layout.addWidget(self.comm) self.setLayout(layout) self.status.set_level(0) # self.status.insert_text("HI") # self.status.verbose("HI") # self.status.debug("HI") # self.status.info("HI") # self.status.warning("HI") # self.status.error("HI") # self.status.critical("HI") def usb_connected(self): if self.programmer: self.programmer.usb_connected() def usb_disconnected(self): if self.programmer: self.programmer.usb_disconnected() def status_server_connected(self): if self.status_server: self.status_server.connected() def status_server_disconnected(self): if self.status_server: self.status_server.disconnected() def data_server_connected(self): if self.data_server: self.data_server.connected() def data_server_disconnected(self): if self.data_server: self.data_server.disconnected() def closeEvent(self, event): self.prometheus.shutdown_server() super(PrometheusGui, self).closeEvent(event) def set_status(self, level, text): if level == 0: self.status.verbose(text) elif level == 1: self.status.debug(text) elif level == 2: self.status.info(text) elif level == 3: self.status.important(text) elif level == 4: self.status.warning(text) elif level == 5: self.status.error(text) elif level == 6: self.status.critical(text) else: utext = "Unknown Level (%d) Text: %s" % (level, text) self.status.insert_text(utext)