def create_ui(item, parent=None): scp = item.open_oscilloscope() if (item.types & libtiepie.DEVICETYPE_OSCILLOSCOPE) != 0 else None if scp: from oscilloscopeui import OscilloscopeUI scpui = OscilloscopeUI(scp, parent) scpui.show() gen = item.open_generator() if (item.types & libtiepie.DEVICETYPE_GENERATOR) != 0 else None if gen: from generatorui import GeneratorUI genui = GeneratorUI(gen, parent) genui.show()
try: libtiepie.device_list.update() dev_count = len(libtiepie.device_list) if dev_count == 0: raise Exception("No devices found") elif dev_count == 1: item = libtiepie.device_list[0] app = QApplication(sys.argv) scp = item.open_oscilloscope() if (item.types & libtiepie.DEVICETYPE_OSCILLOSCOPE) != 0 else None if scp: from oscilloscopeui import OscilloscopeUI scpui = OscilloscopeUI(scp) scpui.show() gen = item.open_generator() if (item.types & libtiepie.DEVICETYPE_GENERATOR) != 0 else None if gen: from generatorui import GeneratorUI genui = GeneratorUI(gen) genui.show() sys.exit(app.exec_()) else: raise Exception("TODO: show dialog to choose instrument.") except Exception, e: print(e.message, file=sys.stderr) sys.exit(1)