Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
class PowerBar(QWidget):
    """Custom Qt Widget to show a power bar and dial.
    Left-clicking the button shows the color-chooser, while
    right-clicking resets the color to None (no-color)."""

    colorChanged = QtCore.Signal()

    def __init__(self, steps: Union[int, List[AllowedColorType]] = 5) -> None:
        super().__init__()

        layout = QVBoxLayout()
        self._bar = _Bar(steps)
        layout.addWidget(self._bar)

        # Create the QDial widget and set up defaults.
        # - we provide accessors on this class to override.
        self._dial = QDial()
        self._dial.setNotchesVisible(True)
        self._dial.setWrapping(False)
        self._dial.valueChanged.connect(self._bar._trigger_refresh)

        # Take feedback from click events on the meter.
        self._bar.clickedValue.connect(self._dial.setValue)

        layout.addWidget(self._dial)
        self.setLayout(layout)

    def __getattr__(self, name: str) -> Any:
        if name in self.__dict__:
            return self[name]
        else:
            return getattr(self._dial, name)

    def setColor(self, color: AllowedColorType) -> None:
        self._bar.steps = [color] * self._bar.n_steps
        self._bar.update()

    def setColors(self, colors: List[AllowedColorType]) -> None:
        self._bar.n_steps = len(colors)
        self._bar.steps = colors
        self._bar.update()

    def setBarPadding(self, i: float) -> None:
        self._bar._padding = int(i)
        self._bar.update()

    def setBarSolidPercent(self, f: float) -> None:
        self._bar._bar_solid_percent = float(f)
        self._bar.update()

    def setBackgroundColor(self, color: AllowedColorType) -> None:
        self._bar._background_color = QtGui.QColor(color)
        self._bar.update()
Exemplo n.º 3
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)
Exemplo n.º 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()