def get_qt_ui(self): """Return a user interface for the experiment""" gb = QuickControlBox("Irradiation Experiment") gb.add_doublespinbox("irradiation_time") gb.add_doublespinbox("wait_time") gb.add_button("start") gb.add_button("stop") gb.auto_connect_by_name(self) return gb
def __init__(self, cwl): super(CameraWithLocationControlUI, self).__init__() self.cwl = cwl cc = QuickControlBox("Settings") cc.add_doublespinbox("calibration_distance") cc.add_button("calibrate_xy_gui", "Calibrate XY") cc.auto_connect_by_name(self) self.calibration_controls = cc fc = QuickControlBox("Autofocus") fc.add_doublespinbox("af_step_size") fc.add_spinbox("af_steps") fc.add_button("autofocus_gui", "Autofocus") fc.add_button("quick_autofocus_gui", "Quick Autofocus") fc.auto_connect_by_name(self.cwl) self.focus_controls = fc # sc = l = QtWidgets.QHBoxLayout() l.addWidget(cc) l.addWidget(fc) self.setLayout(l)
# gb.setLayout(QtGui.QFormLayout()) # # self.gain_spinbox = QtGui.QDoubleSpinBox() # self.gain_spinbox.setObjectName("gain_spinbox") # print "gain spinbox is called " + self.gain_spinbox.objectName() # gb.layout().addRow("Gain:",self.gain_spinbox) # self.exposure_spinbox = QtGui.QDoubleSpinBox() # self.exposure_spinbox.setObjectName("exposure_spinbox") # gb.layout().addRow("Exposure:",self.exposure_spinbox) gb = QuickControlBox() gb.add_doublespinbox("gain") gb.add_doublespinbox("exposure") self.layout().insertWidget(1, gb) # put the extra settings in the middle self.quick_settings_groupbox = gb self.auto_connect_by_name(controlled_object=self.camera, verbose=True) if __name__ == '__main__': cam = MyOpenCVCamera() cam.show_gui() gb = QuickControlBox() gb.add_doublespinbox("gain") gb.add_checkbox("live_view") gb.auto_connect_by_name(cam, verbose=True) gb.show() cam.show_gui()
def toggle(self): """toggle the state of the shutter""" self._open = not self._open def get_state(self): """Return the state of the shutter, a string reading 'open' or 'closed'""" return "Open" if self._open else "Closed" def set_state(self, value): """Set the state of the shutter (to open or closed)""" if isinstance(value, str): self._open = (value.lower() == "open") elif isinstance(value, bool): self._open = value if __name__ == '__main__': import sys app = get_qt_app() shutter = DummyShutter() state_peek = QuickControlBox(title="Internal State") state_peek.add_checkbox("_open", title="Shutter Open") state_peek.auto_connect_by_name(controlled_object=shutter) state_peek.show() ui = shutter.get_qt_ui() ui.show() sys.exit(app.exec_())