grouping radio buttons in PyQt

后端 未结 2 1903
孤独总比滥情好
孤独总比滥情好 2021-01-03 03:24
import sys
from PyQt4 import QtCore, QtGui

class Class1(QtGui.QMainWindow):
    def __init__(self):
        super(Class1, self).__init__()
        self.func()

             


        
2条回答
  •  生来不讨喜
    2021-01-03 03:55

    Grouping of radio buttons can be done by all containers. You don't necessarily need QGroupBox, you can use QFrame instead or a QTabWidget. Your choice. Here's a sample code.

        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.layoutWidget1 = QtWidgets.QWidget(self.centralwidget)
        self.frame_1       = QtWidgets.QFrame(self.layoutWidget1)
        self.radio_btn_a   = QtWidgets.QRadioButton(self.frame_1)
        self.radio_btn_a.setGeometry(QtCore.QRect(160, 80, 40, 17))
        self.radio_btn_a.setObjectName("radio_btn_a")
        MainWindow.setCentralWidget(self.centralwidget)
    

提交回复
热议问题