def testpanel(args=None): """Run simulators. """ parser = argparse.ArgumentParser( description='Open a testpanel. Requires lantz.qt') parser.add_argument('packfile', help='Path of the pack file.', type=common.Packfile.from_file) args = parser.parse_args(args) from lantz.qt.utils.qt import QtGui klass = _load_class(args.packfile.class_spec) from lantz.qt import start_test_app, wrap_driver_cls from lantz.core.log import log_to_screen, DEBUG log_to_screen(DEBUG) Qklass = wrap_driver_cls(klass) with Qklass.via_packfile(args.packfile, check_update=True) as inst: start_test_app(inst)
from app import TemperatureMonitor, TemperatureMonitorUi if __name__ == '__main__': from lantz.core import ureg from lantz.core.log import log_to_screen, log_to_socket, DEBUG from lantz.qt import start_gui_app, wrap_driver_cls # Uncommment this line to log to socket # log_to_socket(DEBUG) # or comment this line to stop logging log_to_screen(DEBUG) # Instead of using the TemperatureSensor driver, we automagically create # a Qt aware version of it. This allows QTemperatureSensor = wrap_driver_cls(TemperatureSensor) # We initialize the board via the packfile to autodetect it. # You can alternative use the COMPORT using the `via_serial` # However, notice that using the packfile is superior as it allows you: # - to check if the software on the arduino is up to date with the version on your computer. # and update it if necessary. # - works even if the comport has changed # - you can specify the model and/or serialno of the board to use a particular one # if you have many connected. # The `with` syntax as equivalent to:
def turn_on_LED_method(self): self.board.led = True def turn_off_LED_method(self): self.board.led = False class LEDUserInterfase(Frontend): gui = 'LED.ui' def connect_backend(self): super().connect_backend() self.widget.turn_on_led_button.clicked.connect( self.backend.turn_on_LED_method) self.widget.turn_off_led_button.clicked.connect( self.backend.turn_off_LED_method) if __name__ == '__main__': from lantz.core.log import log_to_screen, log_to_socket, DEBUG from lantz.qt import start_gui_app, wrap_driver_cls # ~ log_to_socket(DEBUG) # Uncommment this line to log to socket log_to_screen(DEBUG) # or comment this line to stop logging QLED = wrap_driver_cls(LEDDriver) with QLED.via_packfile('LEDDriver.pack.yaml', check_update=True) as board: app = LEDBackend(board=board) start_gui_app(app, LEDUserInterfase)
from uc480.core import Camera from uc480.core import CameraControl, CameraSave, SpectraAnalyzer, SpectraSave, FFTAnalyzer, Main, MainUi #from lantz.qt.app import build_qapp if __name__ == '__main__': from lantz.core.log import log_to_screen, log_to_socket, DEBUG, ERROR, INFO from lantz.qt import start_gui_app, wrap_driver_cls # log_to_socket(DEBUG) log_to_screen(ERROR) QCamera = wrap_driver_cls(Camera) with QCamera() as camera: control_be = CameraControl(camera=camera) camera_save_be = CameraSave(camera_control_be=control_be) spectra_be = SpectraAnalyzer(camera_control_backend=control_be) save_be = SpectraSave(spectra_analyzer_be=spectra_be) fft_be = FFTAnalyzer(spectra_analyzer_backend=spectra_be) app = Main(control_be=control_be, camera_save_be=camera_save_be, spectra_be=spectra_be, save_be=save_be, fft_be=fft_be) start_gui_app(app, MainUi)