def createBottomRightGroupBox(self):
        self.bottomRightGroupBox = QGroupBox("Group 3")
        self.bottomRightGroupBox.setCheckable(True)
        self.bottomRightGroupBox.setChecked(True)

        lineEdit = QLineEdit('s3cRe7')
        lineEdit.setEchoMode(QLineEdit.Password)

        spinBox = QSpinBox(self.bottomRightGroupBox)
        spinBox.setValue(50)

        dateTimeEdit = QDateTimeEdit(self.bottomRightGroupBox)
        dateTimeEdit.setDateTime(QDateTime.currentDateTime())

        slider = QSlider(Qt.Horizontal, self.bottomRightGroupBox)
        slider.setValue(40)

        scrollBar = QScrollBar(Qt.Horizontal, self.bottomRightGroupBox)
        scrollBar.setValue(60)

        dial = QDial(self.bottomRightGroupBox)
        dial.setValue(30)
        dial.setNotchesVisible(True)

        layout = QGridLayout()
        layout.addWidget(lineEdit, 0, 0, 1, 2)
        layout.addWidget(spinBox, 1, 0, 1, 2)
        layout.addWidget(dateTimeEdit, 2, 0, 1, 2)
        layout.addWidget(slider, 3, 0)
        layout.addWidget(scrollBar, 4, 0)
        layout.addWidget(dial, 3, 1, 2, 1)
        layout.setRowStretch(5, 1)
        self.bottomRightGroupBox.setLayout(layout)
Exemple #2
0
    def dialer_changed(self, d: QDial, lab: QLabel):
        value = d.value()

        if (abs(value - self.value_old) > self.value_delta):
            d.setValue(self.value_old)
            value = self.value_old
        else:
            self.value_old = value

        self.disp_value(lab, value)
class MyWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.amtLabel = QLabel('Loan Amount')
        self.roiLabel = QLabel('Rate of Interest')
        self.yrsLabel = QLabel('No. of Years')
        self.emiLabel = QLabel('EMI per month')
        self.emiValue = QLCDNumber()
        self.emiValue.setSegmentStyle(QLCDNumber.Flat)
        self.emiValue.setFixedSize(QSize(130, 30))
        self.emiValue.setDigitCount(8)
        self.amtText = QLineEdit('10000')
        self.roiSpin = QSpinBox()
        self.roiSpin.setMinimum(1)
        self.roiSpin.setMaximum(15)
        self.yrsSpin = QSpinBox()
        self.yrsSpin.setMinimum(1)
        self.yrsSpin.setMaximum(20)
        self.roiDial = QDial()
        self.roiDial.setNotchesVisible(True)
        self.roiDial.setMaximum(15)
        self.roiDial.setMinimum(1)
        self.roiDial.setValue(1)
        self.yrsSlide = QSlider(Qt.Horizontal)
        self.yrsSlide.setMaximum(20)
        self.yrsSlide.setMinimum(1)
        self.calculateButton = QPushButton('Calculate EMI')
        self.myGridLayout = QGridLayout()
        self.myGridLayout.addWidget(self.amtLabel, 0, 0)
        self.myGridLayout.addWidget(self.roiLabel, 1, 0)
        self.myGridLayout.addWidget(self.yrsLabel, 2, 0)
        self.myGridLayout.addWidget(self.amtText, 0, 1)
        self.myGridLayout.addWidget(self.roiSpin, 1, 1)
        self.myGridLayout.addWidget(self.yrsSpin, 2, 1)
        self.myGridLayout.addWidget(self.roiDial, 1, 2)
        self.myGridLayout.addWidget(self.yrsSlide, 2, 2)
        self.myGridLayout.addWidget(self.calculateButton, 3, 1)
        self.setLayout(self.myGridLayout)
        self.setWindowTitle("A simple EMI calculator")
        self.roiDial.valueChanged.connect(self.roiSpin.setValue)
        self.connect(self.roiSpin, SIGNAL("valueChanged(int)"), self.roiDial.setValue)
        self.yrsSlide.valueChanged.connect(self.yrsSpin.setValue)
        self.connect(self.yrsSpin, SIGNAL("valueChanged(int)"),self.yrsSlide, SLOT("setValue(int)"))
        self.connect(self.calculateButton, SIGNAL("clicked()"),self.showEMI)

    def showEMI(self):
        loanAmount = float(self.amtText.text())
        rateInterest = float(float(self.roiSpin.value() / 12) / 100)
        noMonths = int(self.yrsSpin.value() * 12)
        emi = (loanAmount * rateInterest) * ((((1 + rateInterest) ** noMonths) / (((1 + rateInterest) ** noMonths) - 1)))
        self.emiValue.display(emi)
        self.myGridLayout.addWidget(self.emiLabel, 4, 0)
        self.myGridLayout.addWidget(self.emiValue, 4, 2)
Exemple #4
0
    def initUI(self):
        dial = QDial()
        dial.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        dial.setNotchesVisible(True)
        dial.setMinimum(self.value_min)
        dial.setMaximum(self.value_max)
        dial.setValue(self.value_old)
        dial.valueChanged.connect(lambda: self.dialer_changed(dial, label))

        label = QLabel()
        self.disp_value(label, self.value_old)

        vbox = QVBoxLayout()
        vbox.addWidget(dial)
        vbox.addWidget(label)
        self.setLayout(vbox)
        self.show()
def init_item_rotation_layout(item):
    current_rotation = item.rotation()
    label_layout = QHBoxLayout()
    label_layout.addWidget(QLabel("Rotation"))
    rotation_value_label = QLabel(str(current_rotation) + " \N{DEGREE SIGN}")
    label_layout.addWidget(rotation_value_label)
    rotation_layout = QVBoxLayout()
    rotation_layout.addLayout(label_layout)
    rotation_input = QDial()
    rotation_input.setMinimum(0)
    rotation_input.setMaximum(359)
    rotation_input.setSingleStep(1)
    rotation_input.setWrapping(True)
    rotation_input.setValue(int(current_rotation))
    rotation_input.valueChanged.connect(lambda current_value:
                                        set_item_rotation(
                                            current_value, item,
                                            rotation_value_label))
    rotation_layout.addWidget(rotation_input)
    return rotation_layout
class Potentiometre(QWidget):
    def __init__(self):
        '''Class d'initialisation des 3 potentiometres

=> Les fonctions à la fin (knob1,2,3 et ligne1,2,3) permettent de synchroniser la valeur du potentiometre avec le lineEdit
=> dial1 > Translation Z ; dial2 > Rotation Y ; dial3 > Rotation X
        '''
        QWidget.__init__(self)
        self.__restriction1 = QIntValidator(-180, 180)
        self.__restriction2 = QDoubleValidator(-10, 10, 2)

        A = QFont("DIN Condensed", 70)
        self.titre = QLabel("S T L   B O A T")
        self.titre.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
        #self.titre.adjustSize()
        self.titre.setFont(A)

        self.dial1 = QDial()
        self.dial1.setValue(0)
        self.dial1.setMaximum(100)
        self.dial1.setMinimum(-100)
        self.dial1.valueChanged.connect(self.knob1)
        self.dial2 = QDial()
        self.dial2.valueChanged.connect(self.knob2)
        self.dial2.setMinimum(-180)
        self.dial2.setMaximum(180)
        self.dial2.setValue(0)
        self.dial3 = QDial()
        self.dial3.setMinimum(-180)
        self.dial3.setMaximum(180)
        self.dial3.setValue(0)
        self.dial3.valueChanged.connect(self.knob3)
        self.layout = QGridLayout()
        self.__lab1 = QLabel('Translation Z (m)')
        self.__lab1.setAlignment(QtCore.Qt.AlignCenter
                                 | QtCore.Qt.AlignVCenter)
        self.__lab2 = QLabel('Rotation Y (deg)')
        self.__lab2.setAlignment(QtCore.Qt.AlignCenter
                                 | QtCore.Qt.AlignVCenter)
        self.__lab3 = QLabel('Rotation X (deg)')
        self.__lab3.setAlignment(QtCore.Qt.AlignCenter
                                 | QtCore.Qt.AlignVCenter)
        self.line1 = QLineEdit()
        self.line1.setValidator(self.__restriction2)
        self.line1.editingFinished.connect(self.ligne1)
        self.line1.setText('0')
        self.line2 = QLineEdit()
        self.line2.setValidator(self.__restriction1)
        self.line2.editingFinished.connect(self.ligne2)
        self.line2.setText('0')
        self.line3 = QLineEdit()
        self.line3.setValidator(self.__restriction1)
        self.line3.setText('0')
        self.line3.editingFinished.connect(self.ligne3)
        self.layout.addWidget(self.titre, 0, 0, 1, 0)
        self.layout.addWidget(self.dial1, 1, 0)
        self.layout.addWidget(self.dial2, 1, 1)
        self.layout.addWidget(self.dial3, 1, 2)
        self.layout.addWidget(self.__lab1, 2, 0)
        self.layout.addWidget(self.__lab2, 2, 1)
        self.layout.addWidget(self.__lab3, 2, 2)
        self.layout.addWidget(self.line1, 3, 0)
        self.layout.addWidget(self.line2, 3, 1)
        self.layout.addWidget(self.line3, 3, 2)
        self.setLayout(self.layout)
        self.show()

    def knob1(self):
        self.line1.setText(str(self.dial1.value() / 10))

    def knob2(self):
        self.line2.setText(str(self.dial2.value()))

    def knob3(self):
        self.line3.setText(str(self.dial3.value()))

    def ligne1(self):
        #self.dial1.setValue(int(self.line1.text()))
        a = self.line1.text()
        #a=str(a.replace(',','.'))
        print(a)
        self.dial1.setValue(float(a) * 10)

    def ligne2(self):
        self.dial2.setValue(float(self.line2.text()))

    def ligne3(self):
        self.dial2.setValue(float(self.line3.text()))
Exemple #7
0
class UhrWindow(QDialog):
    """Uhr dialog menu with dial"""
    def __init__(self, master, uhr_position):
        """
        Uhr plugboard device
        :param master: Qt parent widget
        :param uhr_position: {callable} Sets the indicator to the current
                                        uhr position (if any)
        """
        super().__init__(master)

        # QT WINDOW SETTINGS ===================================================

        self.setWindowTitle("Uhr")
        self.setFixedSize(300, 400)
        main_layout = QVBoxLayout(self)
        self.setLayout(main_layout)

        # UHR POSITION DIAL ====================================================

        self.__indicator = QLabel("00")
        self.__indicator.setStyleSheet(
            "font-size: 20px; text-align: center; background-color: white")
        self.__indicator.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.__indicator.setFixedSize(40, 40)
        self.__indicator.setLineWidth(2)

        self.__dial = QDial()
        self.__dial.setWrapping(True)
        self.__dial.setRange(0, 39)
        self.__dial.setFixedSize(280, 280)
        self.__dial.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        position = 0
        try:
            position = uhr_position()
            logging.info("Successfully loaded Uhr position %d from plug...",
                         position)
        except ValueError:
            logging.info(
                "Failed loading Uhr position from plug, setting to 0...")

        self.__dial.setValue(position)
        self.__old_position = position
        self.__indicator.setText("%02d" % position)
        self.__dial.valueChanged.connect(self.refresh_indicator)

        # BUTTONS ==============================================================

        apply_btn = QPushButton("Apply")
        apply_btn.clicked.connect(self.apply)
        storno_btn = QPushButton("Storno")
        storno_btn.clicked.connect(self.storno)
        btn_frame = QFrame(self)
        btn_layout = QHBoxLayout(btn_frame)

        # SHOW WIDGETS =========================================================

        btn_layout.addWidget(storno_btn)
        btn_layout.addWidget(apply_btn)
        main_layout.addWidget(btn_frame)
        main_layout.addWidget(self.__indicator, alignment=Qt.AlignHCenter)
        main_layout.addWidget(self.__dial, alignment=Qt.AlignHCenter)
        main_layout.addWidget(btn_frame)

    def refresh_indicator(self):
        """Sets displayed indicator value to current dial value"""
        self.__indicator.setText("%02d" % self.__dial.value())

    def position(self):
        """Returns current Uhr dial setting"""
        return self.__dial.value()

    def apply(self):
        """Sets currently selected position to be collected when applying settings"""
        self.__old_position = self.__dial.value()
        logging.info("New Uhr position %d applied, closing...",
                     self.__old_position)
        self.close()

    def storno(self):
        """Undoes current changes"""
        logging.info("Storno, reverting to old position %d...",
                     self.__old_position)
        self.__dial.setValue(self.__old_position)
        self.close()