<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<span class="Apple-style-span" style="font-family: verdana, geneva, helvetica, arial, sans-serif; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><div class="message-text" id="nabble.msgtxt26507711" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); ">I am a newbie to Python and have two questions using python to design UI based <br>PyQT4.6. <br><br>The source code is <br>=========================================== <br>#!/usr/bin/python <br>#MyUI.py <br><br>import sys <br>import random <br>from PyQt4 import QtCore, QtGui <br><br><br>class MyUI(QtGui.QWidget): <br> def __init__(self, parent=None): <br> QtGui.QWidget.__init__(self, parent) <br> self.setWindowTitle('My UI') <br><br> cb1 = QtGui.QCheckBox('MyCheckBox1', self) <br> cb2 = QtGui.QCheckBox('MyCheckBox2', self) <br><br> bg = QtGui.QButtonGroup(parent) <br> <br> bg.setExclusive(1) <br> bg.addButton(cb1) <br> bg.addButton(cb2) <br> <br> hbox = QtGui.QHBoxLayout() <br> hbox.addStretch(1) <br> hbox.addWidget(cb1) <br> hbox.addWidget(cb2) <br> self.setLayout(hbox) <br> self.resize(900, 600) <br><br> lb1 = QtGui.QLabel('Name') <br> lb2 = QtGui.QLabel('Age') <br> lb3 = QtGui.QLabel('Address') <br><br> tf1 = QtGui.QLineEdit() <br> tf2 = QtGui.QLineEdit() <br> tf3 = QtGui.QLineEdit() <br> <br> hbox.addWidget(lb1) <br> hbox.addWidget(tf1) <br> hbox.addWidget(lb2) <br> hbox.addWidget(tf2) <br> hbox.addWidget(lb3) <br> hbox.addWidget(tf3) <br> <br> tf1.setText('Jone') <br> tf2.setText('28') <br> tf3.setText('London') <br> <br> update = QtGui.QPushButton('update') <br> hbox.addWidget(update) <br> self.connect(update, QtCore.SIGNAL('clicked()'), <br> self, QtCore.SLOT('update_info(self)')) <br> <br> def update_info(self): <br> tf1.setText('Alice') <br> tf2.setText('18') <br> tf3.setText('New York') <br> <br>app = QtGui.QApplication(sys.argv) <br>ui = MyUI() <br>ui.show() <br>sys.exit(app.exec_()) <br><br><br>============================================ <br><br>I want to implement two functions in this piece of code. <br>1) implement the exclusive checkbox in a group of checkboxes. In another word, <br>only one of CheckBox1 and Checkbox2 could be checked at any time. <br><br>2) After clicking "update" button, the information should be updated as <br>Name ----> Alice <br>Age -----> 18 <br>Address---> New York <br><br><br>How should the code be modified to implement this two functionalities? <br><br>Many thanks. <br></div><div class="ad" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); margin-top: 2em; "><ins style="display: inline-table; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; height: 60px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; position: relative; visibility: visible; width: 468px; "></ins></div></span>                                            <br /><hr />Hotmail: Trusted email with powerful SPAM protection. <a href='http://clk.atdmt.com/GBL/go/177141665/direct/01/' target='_new'>Sign up now.</a></body>
</html>