BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
microscope.gui.LightSourceWidget Class Reference
Inheritance diagram for microscope.gui.LightSourceWidget:

Public Member Functions

None __init__ (self, microscope.abc.LightSource device, *args, **kwargs)
 
None updateEnableState (self)
 
None updateCurrentPower (self)
 

Public Attributes

 updateEnableState
 
 updateCurrentPower
 

Protected Attributes

 _device = device
 
 _enable_check = QtWidgets.QCheckBox("Enabled", parent=self)
 
 _set_power_box = QtWidgets.QDoubleSpinBox(parent=self)
 
 _current_power
 
 _get_power_timer = QtCore.QTimer(self)
 

Detailed Description

Definition at line 345 of file gui.py.

Constructor & Destructor Documentation

◆ __init__()

None microscope.gui.LightSourceWidget.__init__ ( self,
microscope.abc.LightSource device,
* args,
** kwargs )

Definition at line 346 of file gui.py.

348 ) -> None:
349 super().__init__(*args, **kwargs)
350 self._device = device
351
352 self._enable_check = QtWidgets.QCheckBox("Enabled", parent=self)
353 self._enable_check.stateChanged.connect(self.updateEnableState)
354
355 self._set_power_box = QtWidgets.QDoubleSpinBox(parent=self)
356 self._set_power_box.setMinimum(0.0)
357 self._set_power_box.setMaximum(1.0)
358 self._set_power_box.setValue(self._device.power)
359 self._set_power_box.setSingleStep(0.01)
360 self._set_power_box.setAlignment(QtCore.Qt.AlignRight)
361 self._set_power_box.valueChanged.connect(
362 lambda x: setattr(self._device, "power", x)
363 )
364
365 self._current_power = QtWidgets.QLineEdit(
366 str(self._device.power), parent=self
367 )
368 self._current_power.setReadOnly(True)
369 self._current_power.setAlignment(QtCore.Qt.AlignRight)
370
371 self._get_power_timer = QtCore.QTimer(self)
372 self._get_power_timer.timeout.connect(self.updateCurrentPower)
373 self._get_power_timer.setInterval(500) # msec
374
375 self.updateEnableState()
376
377 layout = QtWidgets.QVBoxLayout()
378 layout.addWidget(self._enable_check)
379 power_layout = QtWidgets.QFormLayout()
380 power_layout.addRow("Set power", self._set_power_box)
381 power_layout.addRow("Current power", self._current_power)
382 layout.addLayout(power_layout)
383 self.setLayout(layout)
384

Member Function Documentation

◆ updateCurrentPower()

None microscope.gui.LightSourceWidget.updateCurrentPower ( self)

Definition at line 408 of file gui.py.

408 def updateCurrentPower(self) -> None:
409 self._current_power.setText(str(self._device.power))
410
411

◆ updateEnableState()

None microscope.gui.LightSourceWidget.updateEnableState ( self)
Update UI and light source state after enable check box

Definition at line 385 of file gui.py.

385 def updateEnableState(self) -> None:
386 """Update UI and light source state after enable check box"""
387 if self._enable_check.isChecked():
388 self._device.enable()
389 else:
390 self._device.disable()
391
392 device_is_enabled = self._device.get_is_enabled()
393
394 if self._enable_check.isChecked() != device_is_enabled:
395 self._enable_check.setChecked(device_is_enabled)
396 _logger.error(
397 "failed to %s light",
398 "enable" if self._enable_check.isChecked() else "disable",
399 )
400
401 self._current_power.setEnabled(device_is_enabled)
402 if device_is_enabled:
403 self._get_power_timer.start()
404 else:
405 self._get_power_timer.stop()
406 self._current_power.setText("0.0")
407

Member Data Documentation

◆ _current_power

microscope.gui.LightSourceWidget._current_power
protected
Initial value:
= QtWidgets.QLineEdit(
str(self._device.power), parent=self
)

Definition at line 365 of file gui.py.

◆ _device

microscope.gui.LightSourceWidget._device = device
protected

Definition at line 350 of file gui.py.

◆ _enable_check

microscope.gui.LightSourceWidget._enable_check = QtWidgets.QCheckBox("Enabled", parent=self)
protected

Definition at line 352 of file gui.py.

◆ _get_power_timer

microscope.gui.LightSourceWidget._get_power_timer = QtCore.QTimer(self)
protected

Definition at line 371 of file gui.py.

◆ _set_power_box

microscope.gui.LightSourceWidget._set_power_box = QtWidgets.QDoubleSpinBox(parent=self)
protected

Definition at line 355 of file gui.py.

◆ updateCurrentPower

microscope.gui.LightSourceWidget.updateCurrentPower

Definition at line 372 of file gui.py.

◆ updateEnableState

microscope.gui.LightSourceWidget.updateEnableState

Definition at line 353 of file gui.py.


The documentation for this class was generated from the following file: