Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何检查PyQt4中的单选按钮和选项列表_Python_Qt_Pyqt4 - Fatal编程技术网

Python 如何检查PyQt4中的单选按钮和选项列表

Python 如何检查PyQt4中的单选按钮和选项列表,python,qt,pyqt4,Python,Qt,Pyqt4,在我的应用程序中,我必须使用PyQt4,并且我希望能够检查单选按钮和选项列表 如果要将参数传递给文本字段类型,请执行以下操作: doc = QWebView.page().mainFrame().documentElement() first_name = doc.findFirst("input[id=f_name]") first_name.setAttribute("value", "John") 但是如何设置单选按钮的值: <li id="signup-list-gend

在我的应用程序中,我必须使用PyQt4,并且我希望能够检查单选按钮和选项列表

如果要将参数传递给文本字段类型,请执行以下操作:

doc = QWebView.page().mainFrame().documentElement()
first_name = doc.findFirst("input[id=f_name]")
first_name.setAttribute("value", "John")
但是如何设置单选按钮的值:

    <li id="signup-list-gender" class="gender" >
                    <span class="gender-label">     Gender:
<span class="formNote">(Optional)</span></span>
                    <label for="signup-gender-male"><input id="signup-gender-male" class="gender" tabindex="9" type="radio" name="gender" value="m" > Male</label>
                    <label for="signup-gender-female"><input id="signup-gender-female" class="gender" tabindex="10" type="radio" name="gender" value="f" > Female</label>
                </li>
                <li id="signup-list-birthdate" class="birthdate">
  • 性别: (可选) 男性 女性

  • 您需要在单选按钮上设置属性化的“checked”,类似这样(我没有测试此代码):

    对于单选按钮属性检查

    doc = QWebView.page().mainFrame().documentElement()
    male = doc.findFirst("input[id=signup-gender-male]")
    male.setAttribute("checked", "true")