예제 #1
0
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)
예제 #2
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()
예제 #3
0
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
예제 #4
0
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()))