osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.


Hi

How do I publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

Thanks

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'laser.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from pyqtconfig import ConfigManager

class Ui_Laser(object):
    def setupUi(self, Laser):
        self.config = ConfigManager()
        Laser.setObjectName("Laser")
        Laser.resize(379, 274)
        Laser.setMinimumSize(QtCore.QSize(379, 268))
        self.config.set_defaults({
            'number': 13,
            'number2': 0,
            'number3': 0,
            'number4': 0,
            'number5': 0,
            'number6': 0,
            'on': True,
        })
        self.centralwidget = QtWidgets.QWidget(Laser)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(0, 70, 371, 181))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.spinBox_6 = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox_6.setMaximum(100)
        self.spinBox_6.setObjectName("spinBox_6")
        self.gridLayout.addWidget(self.spinBox_6, 1, 5, 1, 1)
        self.config.add_handler('number', self.spinBox_6)
        self.verticalSlider_2 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_2.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_2.setObjectName("verticalSlider_2")
        self.gridLayout.addWidget(self.verticalSlider_2, 0, 1, 1, 1)
        self.verticalSlider_5 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_5.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_5.setObjectName("verticalSlider_5")
        self.gridLayout.addWidget(self.verticalSlider_5, 0, 4, 1, 1)
        self.spinBox = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox.setMaximum(100)
        self.spinBox.setObjectName("spinBox")
        self.gridLayout.addWidget(self.spinBox, 1, 0, 1, 1)
        self.verticalSlider = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider.setObjectName("verticalSlider")
        self.gridLayout.addWidget(self.verticalSlider, 0, 0, 1, 1)
        self.spinBox_2 = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox_2.setMaximum(100)
        self.spinBox_2.setObjectName("spinBox_2")
        self.gridLayout.addWidget(self.spinBox_2, 1, 1, 1, 1)
        self.verticalSlider_3 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_3.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_3.setObjectName("verticalSlider_3")
        self.gridLayout.addWidget(self.verticalSlider_3, 0, 2, 1, 1)
        self.spinBox_5 = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox_5.setMaximum(100)
        self.spinBox_5.setObjectName("spinBox_5")
        self.gridLayout.addWidget(self.spinBox_5, 1, 4, 1, 1)
        self.verticalSlider_6 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_6.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_6.setObjectName("verticalSlider_6")
        self.gridLayout.addWidget(self.verticalSlider_6, 0, 5, 1, 1)
        self.spinBox_4 = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox_4.setMaximum(100)
        self.spinBox_4.setObjectName("spinBox_4")
        self.gridLayout.addWidget(self.spinBox_4, 1, 3, 1, 1)
        self.verticalSlider_4 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_4.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_4.setObjectName("verticalSlider_4")
        self.gridLayout.addWidget(self.verticalSlider_4, 0, 3, 1, 1)
        self.verticalSlider_7 = QtWidgets.QSlider(self.gridLayoutWidget)
        self.verticalSlider_7.setOrientation(QtCore.Qt.Vertical)
        self.verticalSlider_7.setObjectName("verticalSlider_7")
        self.gridLayout.addWidget(self.verticalSlider_7, 0, 6, 1, 1)
        self.spinBox_3 = QtWidgets.QSpinBox(self.gridLayoutWidget)
        self.spinBox_3.setMaximum(100)
        self.spinBox_3.setObjectName("spinBox_3")
        self.gridLayout.addWidget(self.spinBox_3, 1, 2, 1, 1)
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(0, 50, 41, 19))
        self.pushButton.setCheckable(True)
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QtCore.QRect(50, 50, 41, 19))
        self.pushButton_2.setCheckable(True)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QtCore.QRect(110, 50, 41, 19))
        self.pushButton_3.setCheckable(True)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setGeometry(QtCore.QRect(160, 50, 41, 19))
        self.pushButton_4.setCheckable(True)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setGeometry(QtCore.QRect(220, 50, 41, 19))
        self.pushButton_5.setCheckable(True)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setGeometry(QtCore.QRect(270, 50, 41, 19))
        self.pushButton_6.setCheckable(True)
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_7.setGeometry(QtCore.QRect(330, 50, 41, 19))
        self.pushButton_7.setCheckable(True)
        self.pushButton_7.setObjectName("pushButton_7")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(0, 40, 39, 11))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(50, 40, 39, 11))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(110, 40, 39, 11))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(160, 40, 39, 11))
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(220, 40, 39, 11))
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setGeometry(QtCore.QRect(270, 40, 39, 11))
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setGeometry(QtCore.QRect(330, 40, 39, 11))
        self.label_7.setObjectName("label_7")
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setGeometry(QtCore.QRect(10, 10, 62, 19))
        self.pushButton_8.setCheckable(True)
        self.pushButton_8.setChecked(True)
        self.pushButton_8.setObjectName("pushButton_8")
        Laser.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(Laser)
        self.statusbar.setObjectName("statusbar")
        Laser.setStatusBar(self.statusbar)

        self.retranslateUi(Laser)
        self.spinBox.valueChanged['int'].connect(self.verticalSlider.setValue)
        print("Value " + str(self.verticalSlider.value()))
        self.spinBox_2.valueChanged['int'].connect(self.verticalSlider_2.setValue)
        self.spinBox_3.valueChanged['int'].connect(self.verticalSlider_3.setValue)
        self.spinBox_4.valueChanged['int'].connect(self.verticalSlider_4.setValue)
        self.spinBox_5.valueChanged['int'].connect(self.verticalSlider_5.setValue)
        self.spinBox_6.valueChanged['int'].connect(self.verticalSlider_6.setValue)
        QtCore.QMetaObject.connectSlotsByName(Laser)

    def retranslateUi(self, Laser):
        _translate = QtCore.QCoreApplication.translate
        Laser.setWindowTitle(_translate("Laser", "MainWindow"))
        self.pushButton.setText(_translate("Laser", "ON"))
        self.pushButton_2.setText(_translate("Laser", "ON"))
        self.pushButton_3.setText(_translate("Laser", "ON"))
        self.pushButton_4.setText(_translate("Laser", "ON"))
        self.pushButton_5.setText(_translate("Laser", "ON"))
        self.pushButton_6.setText(_translate("Laser", "ON"))
        self.pushButton_7.setText(_translate("Laser", "ON"))
        self.label.setText(_translate("Laser", "445nm"))
        self.label_2.setText(_translate("Laser", "488nm"))
        self.label_3.setText(_translate("Laser", "515nm"))
        self.label_4.setText(_translate("Laser", "561nm"))
        self.label_5.setText(_translate("Laser", "594nm"))
        self.label_6.setText(_translate("Laser", "638nm"))
        self.label_7.setText(_translate("Laser", "LED"))
        self.pushButton_8.setText(_translate("Laser", "ON"))
        self.config.add_handler('on', self.pushButton_8)

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Laser = QtWidgets.QMainWindow()
    ui = Ui_Laser()
    ui.setupUi(Laser)
    Laser.show()
    sys.exit(app.exec_())