圆月山庄资源网 Design By www.vgjia.com


复制代码 代码如下:
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
class MyWindow(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self,parent )
        self.setWindowTitle("weather")
        self.resize(1000, 200)
        girdLayout = QtGui.QGridLayout()
        #标签
        str ="weather"
        label1 = QtGui.QLabel(str)
        girdLayout.addWidget( label1, 0, 0)
        #按钮
        button1 = QtGui.QPushButton('button1')
        girdLayout.addWidget ( button1 , 0, 1)
        #文本条
        textFile = QtGui.QLineEdit()
        girdLayout.addWidget( textFile, 0, 2 )
        #密码条
        passwordFile = QtGui.QLineEdit()
        passwordFile.setEchoMode( QtGui.QLineEdit.Password )
        girdLayout.addWidget( passwordFile, 1, 2)
        #编辑框
        textArea = QtGui.QTextEdit()
        girdLayout.addWidget(textArea , 2, 2 )
        #单选框&复选框
        self.radio1 = QtGui.QRadioButton('radio1')
        self.radio2 = QtGui.QRadioButton('radio2')
        self.radio3 = QtGui.QRadioButton('radio3')
        girdLayout.addWidget( self.radio1 , 3 ,0)
        girdLayout.addWidget( self.radio2 , 3 ,1)
        girdLayout.addWidget( self.radio3 , 3 ,2)
        checkbox1 = QtGui.QCheckBox('checkbox1')
        checkbox2 = QtGui.QCheckBox('checkbox2')
        checkbox3 = QtGui.QCheckBox('checkbox2')
        girdLayout.addWidget( checkbox1 , 4, 0)
        girdLayout.addWidget( checkbox2 , 4, 1)
        girdLayout.addWidget( checkbox3 , 4, 2)

        self.button = QtGui.QPushButton('ok')
        girdLayout.addWidget( self.button, 5 , 0)

        self.connect(self.button ,QtCore.SIGNAL('clicked()'),self.OnButton )
        self.setLayout( girdLayout) 

    def OnButton(self ):
            if self.radio2.isChecked():
                self.radio2.setText('haha')

       

app = QtGui.QApplication( sys.argv )
mywindow = MyWindow()
mywindow.show()
app.exec_()

标签:
pyqt4教程,widget

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com