首页 > 其他 > 详细

pyqt5-010

时间:2020-05-17 11:32:12      阅读:55      评论:0      收藏:0      [点我收藏+]

QRadioButton:

  描述:

    一般用于给用户提供拖杆选项中的单选操作:

      比如:

        性别:(男;女)

        答案:(是;否)

      当选中一个时,会自动取消上一个

  继承:QAbstractButton

  功能作用:

    创建单选按钮:

      QRadioButton(parent)

      QRadioButton(text, parent)

    常用继承父类操作:

      图标:setIcon(QIcon)

      快捷键:

        文本加该

        setShortcut()

  信号:

    均继承自父类

    常用信号为:toggled(bool)

 

from PyQt5.Qt import *
import sys
app = QApplication(sys.argv)
window = QWidget()
window.resize(300,300)
window.setWindowTitle(QRadioButton-功能)

red = QWidget(window)
red.resize(100, 150)
red.setStyleSheet(background-color: red;)
red.move(50, 50)

green = QWidget(window)
green.resize(100, 100)
green.setStyleSheet(background-color: green;)
green.move(red.x() + red.width(), red.y() + red.height())


# rb_man = QRadioButton(‘男-&Male‘, window)
# 设置快捷键
rb_man = QRadioButton(, red)
rb_man.setShortcut(Alt+M)
# 设置快捷键
rb_man.move(10, 10)
rb_man.setChecked(True)

# rb_woman = QRadioButton(‘女-&FMale‘, window)
rb_woman = QRadioButton(, red)
rb_woman.setShortcut(Alt+F)
rb_woman.move(10, 40)
rb_woman.setIcon(QIcon(click.jpg))
rb_woman.setIconSize(QSize(20, 20))
rb_woman.toggled.connect(lambda isChecked: print(isChecked))
# 状态更改函数

# rb_woman.setAutoExclusive(False)
# 设立独占特性


rb_yes = QRadioButton(yes, green)
rb_yes.move(0, 0)
rb_no = QRadioButton(no, green)
rb_no.move(0, 30)


window.show()
sys.exit(app.exec_())

 

    

pyqt5-010

原文:https://www.cnblogs.com/superSmall/p/12900331.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!