首页 > 编程 > Python > 正文

python3.2 + PyQt4界面开发hello world

2019-11-15 01:29:22
字体:
来源:转载
供稿:网友
python3.2 + PyQt4界面开发hello world

需要先安装python3.2 然后安装python3.2对应的PyQt4界面库版本

import sysfrom PyQt4 import QtGui , QtCoreapp = QtGui.Qapplication( sys.argv )widget = QtGui.QWidget()widget.resize( 250 , 150 )widget.setWindowTitle( '窗口标题' )# 设置图标widget.setWindowIcon( QtGui.QIcon( '16-111129230521' ) )# 设置窗口中间部分的文字tip提示widget.setToolTip( '<b>文字提示:::</b>' )QtGui.QToolTip.setFont( QtGui.QFont( 'OldEnglish' , 12 ) )# 退出按钮quit = QtGui.QPushButton( '退出' , widget )quit.setGeometry( 10 ,20 , 50 ,30 )# 退出按钮 连接 到py的信号槽机制widget.connect( quit , QtCore.SIGNAL( 'clicked()' ) , QtGui.qApp , QtCore.SLOT( 'quit()' )  )reply = QtGui.QMessageBox.question( widget , 'message' , '问题?' , QtGui.QMessageBox.Yes , QtGui.QMessageBox.No )# 显示窗体部件widget.show()sys.exit( app.exec_() )


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表