繁体   English   中英

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

[英]How to check radio buttons and option list in PyQt4

在我的应用程序中,我必须使用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")

对于单选按钮属性,请在此处检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM