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_())

 

posted @ 2020-05-15 14:53  样子2018  阅读(2037)  评论(0编辑  收藏  举报