pyqt4教程之实现windows窗口小示例分享
import sys
from PyQt4 import QtGui, QtCore
class Window( QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setWindowTitle('hello')
self.resize(800,500)
menubar = self.menuBar()
self.file = menubar.addMenu('&file')
open = self.file.addAction('open')
self.connect(open,QtCore.SIGNAL('triggered()'),self.OnOpen)
save =self.file.addAction('save')
self.connect(save,QtCore.SIGNAL('triggered()'),self.OnSave)
self.file.addSeparator()
close = self.file.addAction('close')
self.connect(close,QtCore.SIGNAL('triggered()'),self.OnClose)
self.label = QtGui.QLabel('this is a google text')
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.setCentralWidget(self.label)
def OnOpen(self):
self.label.setText('open')
def OnClose(self):
self.close()
def OnSave( self):
self.label.setText('save')
def contextMenuEvent(self,event):
self.file.exec_( event.globalPos())
app =QtGui.QApplication(sys.argv)
win = Window()
win.show()
app.exec_()
相关文章
解决python多线程报错:AttributeError: Can''t pickle local object问题
这篇文章主要介绍了解决python多线程报错:AttributeError: Can't pickle local object问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-04-04
Python3网络爬虫之使用User Agent和代理IP隐藏身份
这篇文章主要介绍了Python3网络爬虫之使用User Agent和代理IP隐藏身份,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-11-11


最新评论