mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-12-22 16:27:48 +00:00
Added settings in a grid to preserve space.
This commit is contained in:
parent
8a1fdb99db
commit
13c4910630
3 changed files with 29 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from PyQt6.QtWidgets import QWidget, QLabel, QLineEdit, QHBoxLayout, QSizePolicy, QSpacerItem
|
from PyQt6.QtWidgets import QWidget, QLabel, QLineEdit, QHBoxLayout, QSizePolicy, QSpacerItem, QVBoxLayout
|
||||||
|
from PyQt6.QtCore import Qt
|
||||||
from nqrduck.module.module_view import ModuleView
|
from nqrduck.module.module_view import ModuleView
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -21,17 +22,24 @@ class BaseSpectrometerView(ModuleView):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self._ui_form.setupUi(self)
|
self._ui_form.setupUi(self)
|
||||||
|
|
||||||
|
grid = self._ui_form.gridLayout
|
||||||
|
self._ui_form.verticalLayout.removeItem(self._ui_form.gridLayout)
|
||||||
# Add name of the spectrometer to the view
|
# Add name of the spectrometer to the view
|
||||||
label = QLabel("%s Settings:" % self.module.model.toolbar_name)
|
label = QLabel("%s Settings:" % self.module.model.toolbar_name)
|
||||||
label.setStyleSheet("font-weight: bold;")
|
label.setStyleSheet("font-weight: bold;")
|
||||||
self._ui_form.verticalLayout.setSpacing(5)
|
self._ui_form.verticalLayout.setSpacing(5)
|
||||||
self._ui_form.verticalLayout.addWidget(label)
|
self._ui_form.verticalLayout.addWidget(label)
|
||||||
|
self._ui_form.verticalLayout.addLayout(grid)
|
||||||
|
|
||||||
for category in self.module.model.settings.keys():
|
for category_count, category in enumerate(self.module.model.settings.keys()):
|
||||||
logger.debug("Adding settings for category: %s", category)
|
logger.debug("Adding settings for category: %s", category)
|
||||||
|
category_layout = QVBoxLayout()
|
||||||
category_label = QLabel("%s:" % category)
|
category_label = QLabel("%s:" % category)
|
||||||
category_label.setStyleSheet("font-weight: underline;")
|
category_label.setStyleSheet("font-weight: bold;")
|
||||||
self._ui_form.verticalLayout.addWidget(category_label)
|
row = category_count // 2
|
||||||
|
column = category_count % 2
|
||||||
|
|
||||||
|
category_layout.addWidget(category_label)
|
||||||
for setting in self.module.model.settings[category]:
|
for setting in self.module.model.settings[category]:
|
||||||
logger.debug("Adding setting to settings view: %s", setting.name)
|
logger.debug("Adding setting to settings view: %s", setting.name)
|
||||||
|
|
||||||
|
@ -52,9 +60,12 @@ class BaseSpectrometerView(ModuleView):
|
||||||
layout.addWidget(line_edit)
|
layout.addWidget(line_edit)
|
||||||
layout.addStretch(1)
|
layout.addStretch(1)
|
||||||
# Add the layout to the vertical layout of the widget
|
# Add the layout to the vertical layout of the widget
|
||||||
self._ui_form.verticalLayout.addLayout(layout)
|
category_layout.addLayout(layout)
|
||||||
|
|
||||||
|
category_layout.addStretch(1)
|
||||||
|
self._ui_form.gridLayout.addLayout(category_layout, row, column)
|
||||||
|
|
||||||
|
|
||||||
# Push all the settings to the top of the widget
|
# Push all the settings to the top of the widget
|
||||||
self._ui_form.verticalLayout.addStretch(1)
|
self._ui_form.verticalLayout.addStretch(1)
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,14 @@ class Ui_Form(object):
|
||||||
def setupUi(self, Form):
|
def setupUi(self, Form):
|
||||||
Form.setObjectName("Form")
|
Form.setObjectName("Form")
|
||||||
Form.resize(800, 647)
|
Form.resize(800, 647)
|
||||||
self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
|
self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form)
|
||||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.horizontalLayout.addLayout(self.verticalLayout)
|
self.gridLayout = QtWidgets.QGridLayout()
|
||||||
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
|
self.verticalLayout.addLayout(self.gridLayout)
|
||||||
|
self.verticalLayout_2.addLayout(self.verticalLayout)
|
||||||
|
|
||||||
self.retranslateUi(Form)
|
self.retranslateUi(Form)
|
||||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||||
|
|
|
@ -13,9 +13,13 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in a new issue