From b5f57bf4c606bec64d591b6a73f7490704caa6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Wieczorek?= Date: Mon, 18 Jan 2021 11:26:22 +0100 Subject: [PATCH] Refactoring elements of user interface. Update ui files. Set min and max for threshold_slider. Connect threshold_slider with threshold_lcd. Add docstrings. --- src/gui/ui/mainwindow.ui | 14 +++++++++---- src/python/classes/mainwindow.py | 6 ++++++ src/python/ui/mainwindow_ui.py | 34 +++++++++++++++++--------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/gui/ui/mainwindow.ui b/src/gui/ui/mainwindow.ui index ab9c17b..02eef28 100644 --- a/src/gui/ui/mainwindow.ui +++ b/src/gui/ui/mainwindow.ui @@ -533,7 +533,7 @@ - + 0 @@ -562,14 +562,20 @@ QLCDNumber::Filled - 0 + 1 - + + + 1 + + + 128 + Qt::Horizontal @@ -611,7 +617,7 @@ h_line h_line_2 - h_slider + threshold_slider h_line_3 v_spacer_1 check_box_connected_channels diff --git a/src/python/classes/mainwindow.py b/src/python/classes/mainwindow.py index baac0d4..6ee1f04 100644 --- a/src/python/classes/mainwindow.py +++ b/src/python/classes/mainwindow.py @@ -90,6 +90,12 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow): self.preview_label_avatar_4.setPixmap(scaled_pixmap4) self.preview_label_avatar_4.setProperty('path', './src/gui/images/right.png') + self.threshold_slider.valueChanged.connect(self.update_lcd_threshold) + + def update_lcd_threshold(self, event): + """Set threshold value from slider to lcd.""" + self.threshold_lcd.display(event) + def check_file(self, file, extensions): """Check file exist and have good extension.""" if not file: diff --git a/src/python/ui/mainwindow_ui.py b/src/python/ui/mainwindow_ui.py index 5baae14..315fb35 100644 --- a/src/python/ui/mainwindow_ui.py +++ b/src/python/ui/mainwindow_ui.py @@ -223,22 +223,24 @@ class Ui_MainWindow(object): self.label_threshold_description.setMaximumSize(QtCore.QSize(250, 50)) self.label_threshold_description.setObjectName("label_threshold_description") self.h_layout_threshold.addWidget(self.label_threshold_description) - self.lcd_number_of_threshold = QtWidgets.QLCDNumber(self.central_widget) - self.lcd_number_of_threshold.setMinimumSize(QtCore.QSize(0, 30)) - self.lcd_number_of_threshold.setMaximumSize(QtCore.QSize(200, 50)) - self.lcd_number_of_threshold.setFrameShape(QtWidgets.QFrame.Box) - self.lcd_number_of_threshold.setFrameShadow(QtWidgets.QFrame.Raised) - self.lcd_number_of_threshold.setSmallDecimalPoint(False) - self.lcd_number_of_threshold.setDigitCount(3) - self.lcd_number_of_threshold.setSegmentStyle(QtWidgets.QLCDNumber.Filled) - self.lcd_number_of_threshold.setProperty("intValue", 0) - self.lcd_number_of_threshold.setObjectName("lcd_number_of_threshold") - self.h_layout_threshold.addWidget(self.lcd_number_of_threshold) + self.threshold_lcd = QtWidgets.QLCDNumber(self.central_widget) + self.threshold_lcd.setMinimumSize(QtCore.QSize(0, 30)) + self.threshold_lcd.setMaximumSize(QtCore.QSize(200, 50)) + self.threshold_lcd.setFrameShape(QtWidgets.QFrame.Box) + self.threshold_lcd.setFrameShadow(QtWidgets.QFrame.Raised) + self.threshold_lcd.setSmallDecimalPoint(False) + self.threshold_lcd.setDigitCount(3) + self.threshold_lcd.setSegmentStyle(QtWidgets.QLCDNumber.Filled) + self.threshold_lcd.setProperty("intValue", 1) + self.threshold_lcd.setObjectName("threshold_lcd") + self.h_layout_threshold.addWidget(self.threshold_lcd) self.verticalLayout.addLayout(self.h_layout_threshold) - self.h_slider = QtWidgets.QSlider(self.central_widget) - self.h_slider.setOrientation(QtCore.Qt.Horizontal) - self.h_slider.setObjectName("h_slider") - self.verticalLayout.addWidget(self.h_slider) + self.threshold_slider = QtWidgets.QSlider(self.central_widget) + self.threshold_slider.setMinimum(1) + self.threshold_slider.setMaximum(128) + self.threshold_slider.setOrientation(QtCore.Qt.Horizontal) + self.threshold_slider.setObjectName("threshold_slider") + self.verticalLayout.addWidget(self.threshold_slider) self.h_line_3 = QtWidgets.QFrame(self.central_widget) self.h_line_3.setFrameShape(QtWidgets.QFrame.HLine) self.h_line_3.setFrameShadow(QtWidgets.QFrame.Sunken) @@ -261,7 +263,7 @@ class Ui_MainWindow(object): self.verticalLayout.addLayout(self.h_layout_preview_or_generate) self.h_line.raise_() self.h_line_2.raise_() - self.h_slider.raise_() + self.threshold_slider.raise_() self.h_line_3.raise_() self.check_box_connected_channels.raise_() MainWindow.setCentralWidget(self.central_widget)