Home > php教程 > php手册 > python3.2 + PyQt4界面开发hello world

python3.2 + PyQt4界面开发hello world

WBOY
Release: 2016-06-13 09:40:19
Original
1329 people have browsed it

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

 

<span import</span><span  sys
</span><span from</span> PyQt4 <span import</span><span  QtGui , QtCore

app </span>=<span  QtGui.QApplication( sys.argv )

widget </span>=<span  QtGui.QWidget()
widget.resize( </span>250 , 150<span  )
widget.setWindowTitle( </span><span '</span><span 窗口标题</span><span '</span><span  )

</span><span #</span><span  设置图标</span>
widget.setWindowIcon( QtGui.QIcon( <span '</span><span 16-111129230521</span><span '</span><span  ) )

</span><span #</span><span  设置窗口中间部分的文字tip提示</span>
widget.setToolTip( <span '</span><span <b>文字提示:::</b></span><span '</span><span  )
QtGui.QToolTip.setFont( QtGui.QFont( </span><span '</span><span OldEnglish</span><span '</span> , 12<span  ) )

</span><span #</span><span  退出按钮</span>
quit = QtGui.QPushButton( <span '</span><span 退出</span><span '</span><span  , widget )
quit.setGeometry( </span>10 ,20 , 50 ,30<span  )

</span><span #</span><span  退出按钮 连接 到py的信号槽机制</span>
widget.connect( quit , QtCore.SIGNAL( <span '</span><span clicked()</span><span '</span> ) , QtGui.qApp , QtCore.SLOT( <span '</span><span quit()</span><span '</span><span  )  )

reply </span>= QtGui.QMessageBox.question( widget , <span '</span><span message</span><span '</span> , <span '</span><span 问题?</span><span '</span><span  , QtGui.QMessageBox.Yes , QtGui.QMessageBox.No )

</span><span #</span><span  显示窗体部件</span>
<span widget.show()

sys.exit( app.exec_() )</span>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template