pyqt Qbuttongrou


原文链接: pyqt Qbuttongrou
from PyQt5.Qt import *
import sys
import math
 
App=QApplication(sys.argv)
Win=QWidget()
Win.resize(500,500)
Win.setWindowTitle("QButtonGroup-创建和添加按钮")
Win.setWindowIcon(QIcon("D:\ICO\ooopic_1543988618.ico"))
 
 
bg_gender=QButtonGroup(Win)
bg_No=QButtonGroup(Win)
 
rd_na=QRadioButton("男",Win)
rd_na.move(100,100)
rd_na.setIcon(QIcon("D:\ICO\ooopic_1560913577.ico"))
rd_na.setIconSize(QSize(40,40))
rd_na.setShortcut("Alt+M")#设置快捷
rd_na.setChecked(True)#设置为默认选择
 
rd_nv=QRadioButton("女",Win)
rd_nv.move(100,150)
rd_nv.setIcon(QIcon("D:\ICO\ooopic_1560913554.ico"))
rd_nv.setIconSize(QSize(40,40))
rd_nv.setShortcut("Alt+F")#设置快捷
 
rd_NO_1=QRadioButton("1号",Win)
rd_NO_1.move(300,110)
rd_NO_2=QRadioButton("2号",Win)
rd_NO_2.move(300,160)
 
 
bg_gender.addButton(rd_na)
bg_gender.addButton(rd_nv)
 
bg_No.addButton(rd_NO_1)
bg_No.addButton(rd_NO_2)
 
Win.show()
sys.exit(App.exec_())

————————————————
版权声明:本文为CSDN博主「漂泊_人生」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u013934107/article/details/93046058

`