diff --git a/pyglance/glance/gui_view.py b/pyglance/glance/gui_view.py index 059df36df15a92eab08770e305ad40f7ea9a29e7..2c3f1f440d2fa05ad0ac72910808a432de26e338 100644 --- a/pyglance/glance/gui_view.py +++ b/pyglance/glance/gui_view.py @@ -43,6 +43,14 @@ def _add_filler_row(layout): layout.addWidget(QLabel(""), row, 0) layout.setRowStretch(row, 1) +def _add_right_aligned_label(layout, text, row, column=0): + """ + Add a label, right-aligned, to a layout that takes a row + and column and alignment (QGridLayout). + """ + label = QLabel(text) + layout.addWidget(label, row, column, Qt.AlignRight) + return label class _DoubleOrNoneValidator (QDoubleValidator) : """ @@ -186,7 +194,7 @@ class GlanceGUIView (QWidget) : currentRow = self._add_file_related_controls(B_CONST, layoutToUse, currentRow) # set up the epsilon input box - layoutToUse.addWidget(QLabel("epsilon:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "epsilon:", currentRow) self.epsilonWidget = QLineEdit() self.epsilonWidget.setToolTip("Maximum acceptible difference between the variable data in the two files. Leave blank or enter None for no comparison.") tempValidator = _DoubleOrNoneValidator(self.epsilonWidget) @@ -199,7 +207,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 # set up the epsilon percent input box - layoutToUse.addWidget(QLabel("epsilon percent:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "epsilon percent:", currentRow) self.epsilonPerWidget = QLineEdit() self.epsilonPerWidget.setToolTip("Maximum acceptible difference between the variable data in terms of % of each data point in the A file. Leave blank or enter None for no comparison.") tempValidator = _DoubleOrNoneValidator(self.epsilonPerWidget) @@ -212,7 +220,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 # set up the drop down to allow image type selection - layoutToUse.addWidget(QLabel("Image Type:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "Image Type:", currentRow) self.imageSelectionDropDown = QComboBox() self.imageSelectionDropDown.activated.connect(self.reportImageTypeSelected) layoutToUse.addWidget(self.imageSelectionDropDown, currentRow, 1, 1, 2) @@ -248,7 +256,7 @@ class GlanceGUIView (QWidget) : self.widgetInfo[file_prefix] = { } # set up the file loading control - grid_layout.addWidget(QLabel("File " + file_prefix + ":"), currentRow, 0) + _add_right_aligned_label(grid_layout, "File " + file_prefix + ":", currentRow) filePath = QLineEdit() filePath.setToolTip("The currently loaded file.") filePath.setReadOnly(True) # this is mostly for displaying the file path, the load button selects it @@ -265,7 +273,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 # set up the drop down for the variable select - grid_layout.addWidget(QLabel("variable name:"), currentRow, 1) + _add_right_aligned_label(grid_layout, "variable name:", currentRow, 1) variableSelection = QComboBox() variableSelection.setDisabled(True) variableSelection.activated.connect(partial(self.reportVariableSelected, file_prefix=file_prefix)) @@ -275,9 +283,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 # set up a label to display the variable dimension information - tempShapeLabel = QLabel("data shape:") - tempShapeLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - grid_layout.addWidget(tempShapeLabel, currentRow, 1) + _add_right_aligned_label(grid_layout, "data shape:", currentRow, 1) dimensionsLabel = QLabel(" ") self.widgetInfo[file_prefix]['dims'] = dimensionsLabel grid_layout.addWidget(dimensionsLabel, currentRow, 2, 1, 3) @@ -307,7 +313,7 @@ class GlanceGUIView (QWidget) : grid_layout.addWidget(overrideFillButton, currentRow, 1) # now set up the input of the fill value that will be used - grid_layout.addWidget(QLabel("fill value:"), currentRow+1, 1) + _add_right_aligned_label(grid_layout, "fill value:", currentRow + 1, 1) fillValue = QLineEdit() fillValue.setToolTip("The fill value that will be used.") tempValidator = _DoubleOrNoneValidator(fillValue) @@ -335,7 +341,7 @@ class GlanceGUIView (QWidget) : layoutToUse.setColumnStretch(2, 1) # add the drop down for selecting a custom color map - layoutToUse.addWidget(QLabel("Color map:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "Color map:", currentRow) self.colormapDropDown = QComboBox() self.colormapDropDown.activated.connect(self.colormapSelected) layoutToUse.addWidget(self.colormapDropDown, currentRow, 1, 1, 2) @@ -354,7 +360,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 # add the drop down for selecting the data display form - layoutToUse.addWidget(QLabel("Data Form:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "Data Form:", currentRow) self.dataDisplayFormDropDown = QComboBox() self.dataDisplayFormDropDown.activated.connect(self.reportDataFormSelected) layoutToUse.addWidget(self.dataDisplayFormDropDown, currentRow, 1, 1, 2) @@ -375,7 +381,7 @@ class GlanceGUIView (QWidget) : # add lon/lat controls # add box to enter lon/lat epsilon - layoutToUse.addWidget(QLabel("lon/lat epsilon:"), currentRow, 0) + _add_right_aligned_label(layoutToUse, "lon/lat epsilon:", currentRow) llepsilonWidget = QLineEdit() self.llepsilonWidget = llepsilonWidget llepsilonWidget.setToolTip("Maximum acceptible difference between the longitudes or latitudes in the two files. Leave blank or enter None for no comparison.") @@ -396,7 +402,7 @@ class GlanceGUIView (QWidget) : currentRow += 1 return layoutToUse - + def _build_filters_tab (self) : """ built the basic qt controls for the filters tab and lay them out in a grid layout @@ -494,14 +500,13 @@ class GlanceGUIView (QWidget) : """ # add the label so we know which file this is for - tempLabel = QLabel(file_prefix + " Navigation:") + tempLabel = _add_right_aligned_label(grid_layout, file_prefix + " Navigation:", current_row) tempLabel.setToolTip("Navigation variables will only be used when drawing mapped plots.") - grid_layout.addWidget(tempLabel, current_row, 0) current_row += 1 # add drop down to select latitude - grid_layout.addWidget(QLabel("Latitude:"), current_row, 1) + _add_right_aligned_label(grid_layout, "Latitude:", current_row, 1) latNameDropDown = QComboBox() latNameDropDown.activated.connect(partial(self.reportLatitudeSelected, file_prefix=file_prefix)) self.widgetInfo[file_prefix]["latName"] = latNameDropDown @@ -510,7 +515,7 @@ class GlanceGUIView (QWidget) : current_row += 1 # add drop down to select longitude - grid_layout.addWidget(QLabel("Longitude:"), current_row, 1) + _add_right_aligned_label(grid_layout, "Longitude:", current_row, 1) lonNameDropDown = QComboBox() lonNameDropDown.activated.connect(partial(self.reportLongitudeSelected, file_prefix=file_prefix)) self.widgetInfo[file_prefix]["lonName"] = lonNameDropDown