[PyQt] Image doesn't show up

Algis Kabaila akabaila at pcug.org.au
Sun Jun 26 01:28:09 BST 2011


On Sat, 25 Jun 2011 09:49:26 PM Hans-Peter Jansen wrote:
> On Saturday 25 June 2011, 06:57:05 Algis Kabaila wrote:
> > But how to change the old style signal/slot statement to the new
> > style?...
> 
> 	exit.triggered.connect(self.close)
> 
> perhaps?
> 
> Pete

Yes, and QtCore is not used, so not required.  The script becomes:

#!/usr/bin/python
# menubar.py
 
import sys
from PyQt4 import QtGui

class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        
        self.resize(250,150)
        self.setWindowTitle('menubar')
        
        exit = QtGui.QAction(QtGui.QIcon('icons/no.png'),'Exit',self)
        exit.setShortcut('Ctrl+Q')
        exit.setStatusTip('Exit application')
#        
self.connect(exit,QtCore.SIGNAL('triggered()'),QtCore.SLOT('close()'))
        exit.triggered.connect(self.close)
        self.statusBar()
        menubar = self.menuBar()
        file = menubar.addMenu('&File')
        file.addAction(exit)

app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())

IMHO it is neater.  Here is a cigar, Pete!

OldAl.


More information about the PyQt mailing list