From f214b0e06661c40a9de2a01e207c02089611fe14 Mon Sep 17 00:00:00 2001 From: ldam <ldam@passcal.nmt.edu> Date: Wed, 13 Dec 2023 10:41:53 -0700 Subject: [PATCH] adjust last row; rearrange add_row() to be more readable --- .../multi_color_dot_dialog.py | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py b/sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py index 842200588..2291e4408 100644 --- a/sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py +++ b/sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py @@ -137,39 +137,37 @@ class MultiColorDotDialog(EditValueColorDialog): :param rowid: id of current row """ lower_bound_lnedit = QtWidgets.QLineEdit() - self.main_layout.addWidget(lower_bound_lnedit, rowid, 1, 1, 1) - lower_bound_lnedit.setReadOnly(True) - if rowid == 0: - lower_bound_lnedit.setHidden(True) - elif rowid < ROW_TOTAL - 1: - lower_bound_lnedit.setEnabled(False) - else: - lower_bound_lnedit.setHidden(True) + lower_bound_lnedit.setEnabled(False) comparing_text = self.get_comparing_text(rowid) - self.main_layout.addWidget(QtWidgets.QLabel( - comparing_text), rowid, 2, 1, 1) + comparing_label = QtWidgets.QLabel(comparing_text) higher_bound_lnedit = QtWidgets.QLineEdit() validator = BoundValidator() - higher_bound_lnedit.setValidator(validator) - self.main_layout.addWidget(higher_bound_lnedit, rowid, 3, 1, 1) - if rowid == ROW_TOTAL - 1: - higher_bound_lnedit.setEnabled(False) + + if rowid == 0: + lower_bound_lnedit.setHidden(True) + elif rowid == ROW_TOTAL - 1: + higher_bound_lnedit.setHidden(True) select_color_btn = QtWidgets.QPushButton("Select Color") + select_color_btn.clicked.connect( + lambda: self.on_select_color(rowid)) # set focus policy to not be clicked by hitting enter in higher bound select_color_btn.setFocusPolicy(QtCore.Qt.NoFocus) - self.main_layout.addWidget(select_color_btn, rowid, 4, 1, 1) color_label = QtWidgets.QLabel() color_label.setFixedWidth(30) color_label.setAutoFillBackground(True) + + # layout + self.main_layout.addWidget(lower_bound_lnedit, rowid, 1, 1, 1) + self.main_layout.addWidget(comparing_label, rowid, 2, 1, 1) + self.main_layout.addWidget(higher_bound_lnedit, rowid, 3, 1, 1) + self.main_layout.addWidget(select_color_btn, rowid, 4, 1, 1) self.main_layout.addWidget(color_label, rowid, 5, 1, 1) - select_color_btn.clicked.connect( - lambda: self.on_select_color(rowid)) return (lower_bound_lnedit, higher_bound_lnedit, select_color_btn, color_label) @@ -319,9 +317,8 @@ class MultiColorDotDialog(EditValueColorDialog): self.rowid_value_dict = {i: float(self.higher_bound_lnedits[i].text()) for i in range(ROW_TOTAL - 1) if self.higher_bound_lnedits[i].text() != ''} - last_row_lnedit = (self.lower_bound_lnedits[ROW_TOTAL - 1] - if self.upper_equal - else self.higher_bound_lnedits[ROW_TOTAL - 1]) + last_row_lnedit = self.lower_bound_lnedits[ROW_TOTAL - 1] + if len(self.rowid_value_dict) == 0: last_row_lnedit.clear() else: @@ -375,10 +372,8 @@ class MultiColorDotDialog(EditValueColorDialog): self.lower_bound_lnedits[vc_idx + 1].setText(str(value)) else: self.include_greater_than_chkbox.setChecked(True) - if self.upper_equal: - self.lower_bound_lnedits[ROW_TOTAL - 1].setText(str(value)) - else: - self.higher_bound_lnedits[ROW_TOTAL - 1].setText(str(value)) + self.lower_bound_lnedits[ROW_TOTAL - 1].setText(str(value)) + if color == 'not plot': self.set_color_enabled(vc_idx, False) else: @@ -417,11 +412,10 @@ class MultiColorDotDialog(EditValueColorDialog): color = self.color_labels[ROW_TOTAL - 1].palette().window( ).color().name() + val = f"{self.lower_bound_lnedits[ROW_TOTAL - 1].text()}" if self.upper_equal: - val = f"{self.lower_bound_lnedits[ROW_TOTAL - 1].text()}" value_color_list.append(f"{val}<:{color}") else: - val = f"{self.higher_bound_lnedits[ROW_TOTAL - 1].text()}" value_color_list.append(f"={val}:{color}") self.value_color_str = '|'.join(value_color_list) @@ -444,7 +438,7 @@ class MultiColorDotLowerEqualDialog(MultiColorDotDialog): elif rowid < ROW_TOTAL - 1: comparing_text = "<= d <" else: - comparing_text = " d =" + comparing_text = "= d" return comparing_text def set_value(self): -- GitLab