​锋哥原创的PyQt6视频教程:

2024版 PyQt6 Python桌面开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 PyQt6 Python桌面开发 视频教程(无废话版) 玩命更新中~共计33条视频,包括:2024版 PyQt6 Python桌面开发 视频教程(无废话版) 玩命更新中~、第2讲 PyQt6库和工具库QTDesigner安装与配置、第3讲 PyQt6第一个程序HelloWorld实现等,UP主更多精彩视频,请关注UP账号。PyQt6 QRadioButton单选按钮控件-LMLPHPhttps://www.bilibili.com/video/BV11C4y1P7fj/

QRadioButton是单选按钮控件,它为用户提供由两个或多个互斥选项组成的选项集,当用户选中某单选按钮时,同一组中的其他单选按钮不能同时选定。

QRadioButton类的常用方法:

PyQt6 QRadioButton单选按钮控件-LMLPHP

参考代码:

# Form implementation generated from reading ui file 'QRadioButton单选按钮控件.ui'
#
# Created by: PyQt6 UI code generator 6.4.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.radioButton = QtWidgets.QRadioButton(parent=Form)
        self.radioButton.setGeometry(QtCore.QRect(100, 120, 51, 19))
        self.radioButton.setObjectName("radioButton")
        self.radioButton_2 = QtWidgets.QRadioButton(parent=Form)
        self.radioButton_2.setGeometry(QtCore.QRect(140, 120, 51, 19))
        self.radioButton_2.setObjectName("radioButton_2")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.radioButton.setText(_translate("Form", "男"))
        self.radioButton_2.setText(_translate("Form", "女"))
12-03 09:31