PyQt5 之QRadioButton单选框
一、案例
from PyQt5.Qt import * import sys class Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle('QRadioButton-使用') self.resize(500, 400) self.setup_ui() def setup_ui(self): r1 = QRadioButton(self) r1.setText('男') r1.setChecked(True) r1.setIcon(QIcon("xxx.png")) r1.move(200, 100) r2 = QRadioButton(self) r2.setText('女') r2.move(300, 100) if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())