Ejemplo n.º 1
0
    def initUI(self):
        grid = QGridLayout()

        enabled = QCheckBox('Enabled')
        enabled.setObjectName(f"enabled{self.id}")
        enabled.toggle()
        enabled.stateChanged.connect(self.checkbox_update)
        grid.addWidget(enabled, 0, 0)

        amplitude = QDial()
        amplitude.setObjectName(f"amplitude{self.id}")
        amplitude.setMinimum(0)
        amplitude.setMaximum(100)
        amplitude.setValue(100)
        amplitude.setNotchesVisible(True)
        amplitude.setMaximumSize(80, 80)
        amplitude.valueChanged.connect(self.dial_update)
        # amplitude.setEnabled(False)
        grid.addWidget(amplitude, 1, 0)
        #grid.addWidget(amplitude, 0, 0, 2, 1)

        waveform = QComboBox(self)
        waveform.setObjectName(f"waveform{self.id}")
        waveform.addItem("Sine")
        waveform.addItem("Square")
        waveform.addItem("Sawtooth")
        waveform.addItem("Triangle")
        waveform.addItem("Random")
        waveform.currentTextChanged.connect(self.combobox_update)
        
        transpose = QLineEdit(self)
        transpose.setObjectName(f"transpose{self.id}")
        transpose.setValidator(QIntValidator())
        transpose.setMaxLength(3)
        transpose.setText("0")
        transpose.textChanged.connect(self.lineedit_update)
        
        grid.addWidget(waveform, 0, 1)
        grid.addWidget(transpose, 0, 2)
        grid.addWidget(Envelope(self.id), 1, 1)
        self.setLayout(grid)
Ejemplo n.º 2
0
class Ui_Dialog(QDialog):
    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        # 1.
        self.topGroupBox = QGroupBox()
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName('horizontalLayout')

        # 1.1
        self.dial = QDial()
        self.dial.setMaximumSize(QSize(16777215, 16777215))
        self.dial.setObjectName('dial')

        self.horizontalLayout.addWidget(self.dial)

        # 1.2
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName('verticalLayout')

        # 1.2.1
        spacerItem = QSpacerItem(10, 5, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.verticalLayout.addItem(spacerItem)
        # 1.2.2
        self.spinBox = QSpinBox()
        self.spinBox.setObjectName('spinBox')
        self.verticalLayout.addWidget(self.spinBox)

        self.horizontalLayout.addLayout(self.verticalLayout)

        self.topGroupBox.setLayout(self.horizontalLayout)
        # self.topGroupBox.setFlat(True)

        # 2.
        self.line = QFrame()
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName('line')

        # 3.
        self.textBrowser = QTextBrowser()
        self.textBrowser.setObjectName('textBrowser')

        # 网格布局
        self.mainLayout = QGridLayout()
        self.mainLayout.setContentsMargins(4, 4, 4, 4)
        self.mainLayout.addWidget(self.topGroupBox, 0, 0, 1, 1)
        self.mainLayout.addWidget(self.line, 1, 0, 1, 1)
        self.mainLayout.addWidget(self.textBrowser, 2, 0, 1, 1)

        self.setLayout(self.mainLayout)

        self.setObjectName('Dialog')
        self.resize(390, 275)
        self.setSizeGripEnabled(True)
        # self.setWindowTitle("Dialog")

        self.retranslateUi()
        self.spinBox.valueChanged['int'].connect(self.dial.setValue)
        self.dial.valueChanged['int'].connect(self.spinBox.setValue)

        self.show()

    def retranslateUi(self):
        _translate = QCoreApplication.translate
        self.setWindowTitle(_translate("Dialog", "Dialog"))