def __init__(self, dataGenerator, parent=None): super(SpeedButton, self).__init__(parent=parent) self.verticalLayout = QtGui.QVBoxLayout(self) self.speed = 0.25 self.label = QtGui.QLabel(self) self.label.setText("Speed Control") self.label.setFixedHeight(25) self.label.setAlignment(QtCore.Qt.AlignCenter) self.startButton = QtGui.QPushButton('Apply Contingency', self) self.startButton.clicked.connect(dataGenerator.start) self.stopButton = QtGui.QPushButton('Reset', self) #self.stopButton.clicked.connect(dataGenerator.stop) self.fullPlotButton = QtGui.QPushButton("View Full Plot", self) self.zoomButton = QtGui.QPushButton("Zoom Out", self) self.sb1 = QtGui.QRadioButton("x1") self.sb1.toggled.connect(lambda: self.setSpeed(1)) self.sb2 = QtGui.QRadioButton("x0.5") self.sb2.toggled.connect(lambda: self.setSpeed(0.5)) self.sb3 = QtGui.QRadioButton("x0.25") self.sb3.toggled.connect(lambda: self.setSpeed(0.25)) self.sb3.setChecked(True) self.sb4 = QtGui.QRadioButton("x0.10") self.sb4.toggled.connect(lambda: self.setSpeed(0.1)) #self.speedLayout = QtGui.QVBoxLayout() #self.speedLayout.addWidget(self.label) #self.speedLayout.addWidget(self.sb1) self.verticalLayout.setAlignment(QtCore.Qt.AlignTop) self.checkboxLayout = QtGui.QHBoxLayout() self.hl1 = QtGui.QHBoxLayout() self.hl2 = QtGui.QHBoxLayout() self.hl1.addWidget(self.startButton) self.hl1.addWidget(self.stopButton) self.hl2.addWidget(self.fullPlotButton) self.hl2.addWidget(self.zoomButton) self.verticalLayout.addLayout(self.hl1) self.verticalLayout.addLayout(self.hl2) self.verticalLayout.addWidget(self.label) self.checkboxLayout.addWidget(self.sb1) self.checkboxLayout.addWidget(self.sb2) self.checkboxLayout.addWidget(self.sb3) self.checkboxLayout.addWidget(self.sb4) self.verticalLayout.addLayout(self.checkboxLayout)
def __init__(self, parent=None): super(Radiodemo, self).__init__(parent) layout = QtGui.QHBoxLayout() self.b1 = QtGui.QRadioButton("Button1") self.b1.setChecked(True) self.b1.toggled.connect(lambda: self.btnstate(self.b1)) layout.addWidget(self.b1) self.b2 = QtGui.QRadioButton("Button2") self.b2.toggled.connect(lambda: self.btnstate(self.b2)) layout.addWidget(self.b2) self.setLayout(layout) self.setWindowTitle("RadioButton demo")
def initUI(self): horizontalLayout = QtGui.QHBoxLayout() verticalLayout = QtGui.QVBoxLayout() # Menu ---------------------------------- # Creates the first groupBox to hold all the radioButtons; groupBox1 = QtGui.QGroupBox('Algorithms') groupBox1Layout = QtGui.QVBoxLayout() groupBox1.setLayout(groupBox1Layout) # radioButtons; self.bubbleSort_RBtn1 = QtGui.QRadioButton('Unflagged BubbleSort') self.bubbleSort_RBtn2 = QtGui.QRadioButton('Flagged BubbleSort') self.quickSort_RBtn1 = QtGui.QRadioButton( 'QuickSort (Leftmost Elem. as Pivot)') self.quickSort_RBtn2 = QtGui.QRadioButton( 'QuickSort (Middle Elem. as Pivot)') self.insertionSort_RBtn1 = QtGui.QRadioButton('Insertion Sort') self.shellSort_RBtn1 = QtGui.QRadioButton('Shell Sort') self.selectionSort_RBtn1 = QtGui.QRadioButton('Selection Sort') self.heapSort_RBtn1 = QtGui.QRadioButton('Heap Sort') self.mergeSort_RBtn1 = QtGui.QRadioButton('Merge Sort') # Creates the second groupBox to hold all the pushButtons; groupBox2 = QtGui.QGroupBox('Execution') groupBox2Layout = QtGui.QVBoxLayout() groupBox2.setLayout(groupBox2Layout) # pushButtons; self.startBtn = QtGui.QPushButton('Start') self.stopBtn = QtGui.QPushButton('Stop') # Plot Area ----------------------------- # Creates the plotWidget that will display the data being sorted; self.initPlot() # Adds all the Widgets and Layouts; groupBox1Layout.addWidget(self.bubbleSort_RBtn1) groupBox1Layout.addWidget(self.bubbleSort_RBtn2) groupBox1Layout.addWidget(self.quickSort_RBtn1) groupBox1Layout.addWidget(self.quickSort_RBtn2) groupBox1Layout.addWidget(self.insertionSort_RBtn1) groupBox1Layout.addWidget(self.shellSort_RBtn1) groupBox1Layout.addWidget(self.selectionSort_RBtn1) groupBox1Layout.addWidget(self.heapSort_RBtn1) groupBox1Layout.addWidget(self.mergeSort_RBtn1) groupBox2Layout.addWidget(self.startBtn) groupBox2Layout.addWidget(self.stopBtn) verticalLayout.addWidget(groupBox1) verticalLayout.addWidget(groupBox2) verticalLayout.addStretch() horizontalLayout.addLayout(verticalLayout) horizontalLayout.addWidget(self.plotWidget) # Adds all the Events; self.startBtn.clicked.connect(self.clickedStart) self.stopBtn.clicked.connect(self.clickedStop) # Sets the main window; self.setLayout(horizontalLayout) self.setGeometry(100, 100, 800, 600) self.setWindowTitle('VisualSorting') # Checks a default sorting algorithm; self.bubbleSort_RBtn1.setChecked(True) self.stopBtn.setEnabled(False) self.show() sys.exit(self.app.exec_())