diff --git a/pyleco_extras/gui/data_logger/data/DataLogger.ui b/pyleco_extras/gui/data_logger/data/DataLogger.ui index ca1ff02..83c2ddc 100644 --- a/pyleco_extras/gui/data_logger/data/DataLogger.ui +++ b/pyleco_extras/gui/data_logger/data/DataLogger.ui @@ -7,7 +7,7 @@ 0 0 248 - 321 + 353 @@ -49,7 +49,7 @@ 3 - + Takes effect at next measurement start. @@ -109,51 +109,7 @@ - - - - Variables to save. This line is appended to the header. Use time for the time in seconds today. - - - - - - - Values - - - - - - - Header of the save file. - - - QAbstractScrollArea::AdjustToContentsOnFirstShow - - - - - - - Name of the saved file. - - - true - - - - - - - Variable values of the last data point. - - - Variables - - - - + Takes effect immediately! @@ -223,6 +179,64 @@ + + + + Header of the save file. + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + + + + + Name of the saved file. + + + true + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Variables to save. This line is appended to the header. Use time for the time in seconds today. Use leading period to repeat the publisher name. + + + QPlainTextEdit::NoWrap + + + + + + + QPlainTextEdit::NoWrap + + + true + + + + + + @@ -442,7 +456,6 @@ cbValueMean cbRepeat leHeader - leVariables leSavedName tabWidget diff --git a/pyleco_extras/gui/data_logger/data_logger.py b/pyleco_extras/gui/data_logger/data_logger.py index 2bf7790..198f145 100644 --- a/pyleco_extras/gui/data_logger/data_logger.py +++ b/pyleco_extras/gui/data_logger/data_logger.py @@ -137,7 +137,7 @@ def save_data(self, meta: Optional[dict] = None, suffix: str = "") -> str: file_name = self.communicator.ask_handler( method="save_data", timeout=30, - header=f"{self.leHeader.toPlainText()}\n{self.leVariables.text()}", + header=f"{self.leHeader.toPlainText()}\n{self.teVariables.toPlainText()}", meta=meta, suffix=suffix, ) diff --git a/pyleco_extras/gui/data_logger/data_logger_base.py b/pyleco_extras/gui/data_logger/data_logger_base.py index eb1c35f..c4bfb57 100644 --- a/pyleco_extras/gui/data_logger/data_logger_base.py +++ b/pyleco_extras/gui/data_logger/data_logger_base.py @@ -48,9 +48,8 @@ class DataLoggerBase(LECOBaseMainWindowDesigner): cbValueMean: QtWidgets.QRadioButton cbRepeat: QtWidgets.QCheckBox leHeader: QtWidgets.QPlainTextEdit - leVariables: QtWidgets.QLineEdit - lbVariables: QtWidgets.QLabel - lbValues: QtWidgets.QLabel + teVariables: QtWidgets.QPlainTextEdit + teValues: QtWidgets.QPlainTextEdit tabWidget: QtWidgets.QTabWidget toolBar: QtWidgets.QToolBar @@ -279,16 +278,24 @@ def get_configuration(self) -> dict[str, Any]: return config def _read_variables_and_units(self) -> None: - var_text = self.leVariables.text().replace(": ", ":").replace(",", " ") + var_text = self.teVariables.toPlainText().replace(": ", ":").replace(",", " ") raw_vars = var_text.split() + last_name = "" variables = [] units = {} for raw_var in raw_vars: if ":" in raw_var: v, u = raw_var.split(":", maxsplit=1) - units[v] = u else: v = raw_var + u = None + if len(split := v.rsplit(".", maxsplit=1)) > 1: + if split[0]: + last_name = split[0] + elif last_name: + v = ".".join((last_name, split[1])) + if u is not None: + units[v] = u variables.append(v) self._variables = variables self._units = units @@ -298,10 +305,10 @@ def _update_variables_and_units(self) -> None: vars = [] for var in self._variables: if unit := self._units.get(var): - vars.append(":".join((var, unit))) + vars.append(": ".join((var, unit))) else: vars.append(var) - self.leVariables.setText(", ".join(vars)) + self.teVariables.setPlainText(",\n".join(vars)) @property def variables(self) -> Iterable[str]: @@ -443,7 +450,7 @@ def _set_config( if variables is not None: self.variables = variables if variablesText is not None: - self.leVariables.setText(variablesText) + self.teVariables.setPlainText(variablesText) if units is not None: self.units = units if header is not None: @@ -617,8 +624,7 @@ def make_data_point(self) -> None: @pyqtSlot(dict) def show_data_point(self, datapoint: dict[str, Any]) -> None: self.show_list_length() - self.lbVariables.setText("\n".join(datapoint.keys())) - self.lbValues.setText( + self.teValues.setPlainText( "\n".join( f"{value} {self.current_units.get(variable, '')}" for variable, value in datapoint.items() diff --git a/pyleco_extras/gui/data_logger/data_logger_remote.py b/pyleco_extras/gui/data_logger/data_logger_remote.py index 18deb07..6adf41c 100644 --- a/pyleco_extras/gui/data_logger/data_logger_remote.py +++ b/pyleco_extras/gui/data_logger/data_logger_remote.py @@ -94,7 +94,7 @@ def setup_buttons(self) -> None: self.cbRepeat.stateChanged.connect(self.toggleRepeat) # Text self.leHeader.textChanged.connect(self.set_header) - self.leVariables.textEdited.connect(self.set_variables) + self.teVariables.textChanged.connect(self.set_variables) def read_configuration(self) -> dict[str, Any]: try: @@ -237,8 +237,9 @@ def set_header(self) -> None: text = self.leHeader.toPlainText() self.set_property("header", text) - @pyqtSlot(str) - def set_variables(self, text: str) -> None: + @pyqtSlot() + def set_variables(self) -> None: + text = self.teVariables.toPlainText() self.set_property("variablesText", text) "Regular readout" diff --git a/pyleco_extras/gui/data_logger/data_logger_viewer.py b/pyleco_extras/gui/data_logger/data_logger_viewer.py index 897e49b..6924a13 100644 --- a/pyleco_extras/gui/data_logger/data_logger_viewer.py +++ b/pyleco_extras/gui/data_logger/data_logger_viewer.py @@ -67,7 +67,8 @@ def setup_buttons(self) -> None: self.cbValueMean, self.cbRepeat, self.leHeader, - self.leVariables, + self.teVariables, + self.teValues, ): widget.setEnabled(False) self.actionStart.setToolTip("Load a measurement file.")