Skip to content

Commit

Permalink
change Qt element names
Browse files Browse the repository at this point in the history
  • Loading branch information
bleykauf committed May 31, 2024
1 parent 0082c89 commit fd1503d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 62 deletions.
66 changes: 34 additions & 32 deletions linien-gui/linien_gui/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ class MainWindow(QtWidgets.QMainWindow):
power_channel_1: QtWidgets.QLabel
power_channel_2: QtWidgets.QLabel
legend_unlocked: QtWidgets.QHBoxLayout
legend_spectrum_1: QtWidgets.QLabel
legend_spectrum_2: QtWidgets.QLabel
legend_spectrum_combined: QtWidgets.QLabel
spectrum1LegendLabel: QtWidgets.QLabel
spectrum2LegendLabel: QtWidgets.QLabel
combinedSpectrumLegendLabel: QtWidgets.QLabel
sweepControlWidget: SweepControlWidget
sweepAmplitudeSpinBox: CustomDoubleSpinBox
sweepCenterSpinBox: CustomDoubleSpinBox
sweepSlider: SweepSlider
sweepStartStopPushButton: QtWidgets.QPushButton
top_lock_panel: QtWidgets.QWidget
control_std: QtWidgets.QLabel
error_std: QtWidgets.QLabel
legend_control_signal: QtWidgets.QLabel
legend_control_signal_history: QtWidgets.QLabel
legend_error_signal: QtWidgets.QLabel
legend_monitor_signal_history: QtWidgets.QLabel
legend_slow_signal_history: QtWidgets.QLabel
topLockPanelWidget: QtWidgets.QWidget
controlStdLabel: QtWidgets.QLabel
errorStdLabel: QtWidgets.QLabel
controlSignalLegendLabel: QtWidgets.QLabel
controlSignalHistoryLegendLabel: QtWidgets.QLabel
errorSignalLegendLabel: QtWidgets.QLabel
monitorSignalHistoryLegendLabel: QtWidgets.QLabel
slowSignalHistoryLegendLabel: QtWidgets.QLabel
rightPanel: RightPanel
exportParametersButton: QtWidgets.QPushButton
importParametersButton: QtWidgets.QPushButton
newVersionAvailableLabel: QtWidgets.QLabel
pid_parameter_optimization_button: QtWidgets.QPushButton
settings_toolbox: QtWidgets.QToolBox
PIDParameterOptimizationButton: QtWidgets.QPushButton
settingsToolbox: QtWidgets.QToolBox
generalPanel: QtWidgets.QWidget
modSpectroscopyPanel: QtWidgets.QWidget
optimizationPanel: QtWidgets.QWidget
Expand Down Expand Up @@ -134,19 +134,19 @@ def on_connection_established(self):
self.parameters.to_plot.add_callback(self.update_std)

self.parameters.pid_on_slow_enabled.add_callback(
lambda v: self.legend_slow_signal_history.setVisible(v)
lambda v: self.slowSignalHistoryLegendLabel.setVisible(v)
)
self.parameters.dual_channel.add_callback(
lambda v: self.legend_monitor_signal_history.setVisible(not v)
lambda v: self.monitorSignalHistoryLegendLabel.setVisible(not v)
)

self.settings_toolbox.setCurrentIndex(0)
self.settingsToolbox.setCurrentIndex(0)

self.parameters.lock.add_callback(lambda *args: self.reset_std_history())

for color_idx in range(N_COLORS):
getattr(self.app.settings, f"plot_color_{color_idx}").add_callback(
self.update_legend_color
self.on_plot_color_changed
)

self.parameters.dual_channel.add_callback(self.update_legend_text)
Expand All @@ -159,12 +159,12 @@ def change_sweep_control_visibility(self, *args):
self.sweepControlWidget.setVisible(
not al_running and not locked and not optimization
)
self.top_lock_panel.setVisible(locked)
self.topLockPanelWidget.setVisible(locked)
self.statusbar_unlocked.setVisible(
not al_running and not locked and not optimization
)

def update_legend_color(self, *args):
def on_plot_color_changed(self, *args):
def set_color(el, color: Color):
return el.setStyleSheet(
"color: "
Expand All @@ -173,23 +173,23 @@ def set_color(el, color: Color):
)
)

set_color(self.legend_spectrum_1, Color.SPECTRUM1)
set_color(self.legend_spectrum_2, Color.SPECTRUM2)
set_color(self.legend_spectrum_combined, Color.SPECTRUM_COMBINED)
set_color(self.legend_error_signal, Color.SPECTRUM_COMBINED)
set_color(self.legend_control_signal, Color.CONTROL_SIGNAL)
set_color(self.legend_control_signal_history, Color.CONTROL_SIGNAL_HISTORY)
set_color(self.legend_slow_signal_history, Color.SLOW_HISTORY)
set_color(self.legend_monitor_signal_history, Color.MONITOR_SIGNAL_HISTORY)
set_color(self.spectrum1LegendLabel, Color.SPECTRUM1)
set_color(self.spectrum2LgendLabel, Color.SPECTRUM2)
set_color(self.combinedSpectrumLegendLabel, Color.SPECTRUM_COMBINED)
set_color(self.errorSignalLegendLabel, Color.SPECTRUM_COMBINED)
set_color(self.controlSignalLegendLabel, Color.CONTROL_SIGNAL)
set_color(self.controlSignalHistoryLegendLabel, Color.CONTROL_SIGNAL_HISTORY)
set_color(self.slowSignalHistoryLegendLabel, Color.SLOW_HISTORY)
set_color(self.monitorSignalHistoryLegendLabel, Color.MONITOR_SIGNAL_HISTORY)

def update_legend_text(self, dual_channel):
self.legend_spectrum_1.setText(
self.spectrum1LegendLabel.setText(
"error signal" if not dual_channel else "error signal 1"
)
self.legend_spectrum_2.setText(
self.spectrum2LgendLabel.setText(
"monitor" if not dual_channel else "error signal 2"
)
self.legend_spectrum_combined.setVisible(dual_channel)
self.combinedSpectrumLegendLabel.setVisible(dual_channel)

def show(self, host: str, name: str) -> None: # type: ignore[override]
self.setWindowTitle(
Expand Down Expand Up @@ -270,8 +270,10 @@ def update_std(self, to_plot, max_std_history_length=10):
]

if error_signal is not None and control_signal is not None:
self.error_std.setText(f"{np.mean(self.error_std_history):.2f}")
self.control_std.setText(f"{np.mean(self.control_std_history):.2f}")
self.errorStdLabel.setText(f"{np.mean(self.error_std_history):.2f}")
self.controlStdLabel.setText(
f"{np.mean(self.control_std_history):.2f}"
)

def reset_std_history(self):
self.error_std_history = []
Expand Down
52 changes: 26 additions & 26 deletions linien-gui/linien_gui/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QWidget" name="top_lock_panel" native="true">
<widget class="QWidget" name="topLockPanelWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_4">
Expand All @@ -252,7 +252,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="error_std">
<widget class="QLabel" name="errorStdLabel">
<property name="text">
<string>TextLabel</string>
</property>
Expand Down Expand Up @@ -288,7 +288,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="control_std">
<widget class="QLabel" name="controlStdLabel">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -311,7 +311,7 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item>
<widget class="QLabel" name="legend_error_signal">
<widget class="QLabel" name="errorSignalLegendLabel">
<property name="text">
<string>error</string>
</property>
Expand All @@ -321,7 +321,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="legend_control_signal">
<widget class="QLabel" name="controlSignalLegendLabel">
<property name="text">
<string>control</string>
</property>
Expand All @@ -331,7 +331,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="legend_control_signal_history">
<widget class="QLabel" name="controlSignalHistoryLegendLabel">
<property name="text">
<string>control history</string>
</property>
Expand All @@ -341,14 +341,14 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="legend_slow_signal_history">
<widget class="QLabel" name="slowSignalHistoryLegendLabel">
<property name="text">
<string>slow out history</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="legend_monitor_signal_history">
<widget class="QLabel" name="monitorSignalHistoryLegendLabel">
<property name="text">
<string>monitor signal</string>
</property>
Expand Down Expand Up @@ -469,9 +469,9 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="legend_unlocked">
<layout class="QHBoxLayout" name="unlockedLegendLayout">
<item>
<widget class="QLabel" name="legend_spectrum_1">
<widget class="QLabel" name="spectrum1LegendLabel">
<property name="text">
<string>sig1</string>
</property>
Expand All @@ -481,7 +481,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="legend_spectrum_2">
<widget class="QLabel" name="spectrum2LegendLabel">
<property name="text">
<string>sig2</string>
</property>
Expand All @@ -491,7 +491,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QLabel" name="legend_spectrum_combined">
<widget class="QLabel" name="combinedSpectrumLegendLabel">
<property name="text">
<string>combined</string>
</property>
Expand Down Expand Up @@ -592,7 +592,7 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="QPushButton" name="pid_parameter_optimization_button">
<widget class="QPushButton" name="PIDParameterOptimizationButton">
<property name="text">
<string>Noise analysis</string>
</property>
Expand Down Expand Up @@ -1027,7 +1027,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QToolBox" name="settings_toolbox">
<widget class="QToolBox" name="settingsToolbox">
<property name="enabled">
<bool>true</bool>
</property>
Expand All @@ -1054,8 +1054,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<attribute name="label">
Expand All @@ -1072,8 +1072,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<attribute name="label">
Expand All @@ -1090,8 +1090,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<attribute name="label">
Expand All @@ -1108,8 +1108,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<attribute name="label">
Expand All @@ -1131,8 +1131,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -1155,8 +1155,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>400</height>
<width>338</width>
<height>488</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down
8 changes: 4 additions & 4 deletions linien-gui/linien_gui/ui/right_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def ready(self) -> None:
self.main_window.openDeviceManagerButton.clicked.connect(
self.open_device_manager
)
self.main_window.pid_parameter_optimization_button.clicked.connect(
self.main_window.PIDParameterOptimizationButton.clicked.connect(
self.open_psd_window
)

Expand All @@ -49,7 +49,7 @@ def on_connection_established(self) -> None:
self.parameters.lock.add_callback(self.enable_or_disable_panels)

def highlight_psd_button(locked: bool) -> None:
self.main_window.pid_parameter_optimization_button.setStyleSheet(
self.main_window.PIDParameterOptimizationButton.setStyleSheet(
"background: #00aa00;" if locked else ""
)

Expand All @@ -66,15 +66,15 @@ def open_device_manager(self) -> None:

def autolock_status_changed(self, value: bool) -> None:
if value:
self.main_window.settings_toolbox.setCurrentWidget(
self.main_window.settingsToolbox.setCurrentWidget(
self.main_window.lockingPanel
)

self.enable_or_disable_panels()

def optimization_status_changed(self, value: bool) -> None:
if value:
self.main_window.settings_toolbox.setCurrentWidget(
self.main_window.settingsToolbox.setCurrentWidget(
self.main_window.optimizationPanel
)

Expand Down

0 comments on commit fd1503d

Please sign in to comment.