pyqt4教程之實現(xiàn)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網(wǎng)絡爬蟲之使用User Agent和代理IP隱藏身份
這篇文章主要介紹了Python3網(wǎng)絡爬蟲之使用User Agent和代理IP隱藏身份,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
Python中使用 Selenium 實現(xiàn)網(wǎng)頁截圖實例
這篇文章主要介紹了Python中使用 Selenium 實現(xiàn)網(wǎng)頁截圖實例,Selenium支持Java、C#、Ruby 以及 Python等語言,本文以Python語言為例,需要的朋友可以參考下2014-07-07
數(shù)據(jù)挖掘之Apriori算法詳解和Python實現(xiàn)代碼分享
這篇文章主要介紹了數(shù)據(jù)挖掘之Apriori算法詳解和Python實現(xiàn)代碼分享,本文先是對Apriori算法做了詳細介紹,然后給出了Python版實現(xiàn)代碼,需要的朋友可以參考下2014-11-11

