def _on_load(self):
     with signals_blocked(self.spinBox):
         if self._camera and self._camera in self._mmc.getLoadedDevices():
             self.setEnabled(True)
             self.spinBox.setValue(self._mmc.getExposure(self._camera))
         else:
             self.setEnabled(False)
Exemplo n.º 2
0
    def refresh(self) -> None:
        """Update the value of the widget from core.

        (If all goes well this shouldn't be necessary, but if a propertyChanged
        event is missed, this can be used).
        """
        with utils.signals_blocked(self._value_widget):
            self._value_widget.setValue(self._mmc.getProperty(*self._dp))
Exemplo n.º 3
0
 def _on_cfg_set(self, group: str, preset: str) -> None:
     if group == self._group and self._combo.currentText() != preset:
         with signals_blocked(self._combo):
             self._combo.setCurrentText(preset)
             self._combo.setStyleSheet("")
     else:
         dev_prop_list = get_group_dev_prop(group, preset)
         if any(dev_prop for dev_prop in dev_prop_list if dev_prop in self.dev_prop):
             self._set_if_props_match_preset()
Exemplo n.º 4
0
 def _on_sys_cfg_loaded(self):
     with signals_blocked(self._combo):
         self._combo.clear()
         if self._device_label in self._mmc.getLoadedDevices():
             self.setEnabled(True)
             self._refresh_choices()
         else:
             self._combo.addItem(f"{self._device_label!r} not found")
             self.setEnabled(False)
Exemplo n.º 5
0
 def _set_channel_group(self, guessed_channel: str):
     channel_group = guessed_channel
     self._mmc.setChannelGroup(channel_group)
     channel_list = self._mmc.getAvailableConfigs(channel_group)
     with signals_blocked(self.tab_wdg.snap_channel_comboBox):
         self.tab_wdg.snap_channel_comboBox.clear()
         self.tab_wdg.snap_channel_comboBox.addItems(channel_list)
         self.tab_wdg.snap_channel_comboBox.setCurrentText(
             self._mmc.getCurrentConfig(channel_group)
         )
Exemplo n.º 6
0
 def refresh(self) -> None:
     with signals_blocked(self._combo):
         self._combo.clear()
         if self._group not in self._mmc.getAvailableConfigGroups():
             self._combo.addItem(f"No group named {self._group}.")
             self._combo.setEnabled(False)
         else:
             presets = self._mmc.getAvailableConfigs(self._group)
             self._combo.addItems(presets)
             self._combo.setEnabled(True)
Exemplo n.º 7
0
 def _set_if_props_match_preset(self):
     """
     Check if a preset matches the current system state.
     If true, set the combobox to the preset and the text to default color.
     If false, set the combobox text color to 'magenta'.
     """
     for preset in self._presets:
         _set_combo = True
         for (dev, prop, value) in self._mmc.getConfigData(self._group, preset):
             cache_value = self._mmc.getPropertyFromCache(dev, prop)
             if cache_value != value:
                 _set_combo = False
                 break
         if _set_combo:
             with signals_blocked(self._combo):
                 self._combo.setCurrentText(preset)
                 self._combo.setStyleSheet("")
                 return
     # if None of the presets match the current system state
     self._combo.setStyleSheet("color: magenta;")
Exemplo n.º 8
0
 def _on_config_set(self, groupName: str, configName: str):
     if groupName == self._mmc.getOrGuessChannelGroup():
         with signals_blocked(self.tab_wdg.snap_channel_comboBox):
             self.tab_wdg.snap_channel_comboBox.setCurrentText(configName)
Exemplo n.º 9
0
 def _refresh_choices(self) -> None:
     """Refresh the combobox choices from core."""
     with signals_blocked(self._combo):
         self._combo.clear()
         self._combo.addItems(self.stateLabels())
Exemplo n.º 10
0
 def _on_prop_change(self, dev_label: str, prop: str, value: Any) -> None:
     """Update the combobox when the state changes."""
     if dev_label == self._device_label and prop == LABEL:
         with signals_blocked(self._combo):
             self._combo.setCurrentText(value)
Exemplo n.º 11
0
 def _on_exp_changed(self, camera: str, exposure: float):
     if camera == self._camera:
         with signals_blocked(self.spinBox):
             self.spinBox.setValue(exposure)
Exemplo n.º 12
0
 def _on_core_change(dev_label, prop_name, new_val):
     if dev_label == dev and prop_name == prop:
         with utils.signals_blocked(wdg):
             wdg.setValue(new_val)
Exemplo n.º 13
0
 def _refresh_choices(self):
     with utils.signals_blocked(self):
         self.clear()
         self._allowed = self._get_allowed()
         self.addItems(self._allowed)