[PyQt] Fwd: Re: Image doesn't show up
Algis Kabaila
akabaila at pcug.org.au
Mon Jun 27 00:15:28 BST 2011
---------- Forwarded Message ----------
Subject: Re: [PyQt] Image doesn't show up
Date: Mon, 27 Jun 2011, 05:57:20 AM
From: Yaşar Arabacı <yasar11732 at gmail.com>
To: Algis Kabaila <akabaila at pcug.org.au>
Wow, this mail groups are really helpfull. Thanks a lot for all the
information :)
2011/6/26 Algis Kabaila <akabaila at pcug.org.au>
> 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
> > _______________________________________________
> > PyQt mailing list PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> Yaşar, some bonus additions to your good trial script. The images in icons
> directory are from "tango" free open source package.
>
> It is advisable/necessary to have "parent=None" in the __init__ method. As
> the default for parent is already None, why do we need/want to do? I just
> do
> it..
>
> #!/usr/bin/python3
> # menubar.py
>
> import sys
> from PyQt4 import QtGui
>
> class MainWindow(QtGui.QMainWindow):
> # def __init__(self):
> def __init__(self, parent=None):
> super(MainWindow, self).__init__(parent)
> # QtGui.QMainWindow.__init__(self)
> self.resize(300,200)
> self.setWindowTitle('Menu and tool bar.')
> 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)
> toolBar = self.addToolBar('tools')
> toolBar.addAction(exit)
> self.centralwidget = QtGui.QWidget(self)
> self.gridLayout = QtGui.QGridLayout(self.centralwidget)
> self.plainTextEdit = QtGui.QPlainTextEdit(self.centralwidget)
> self.gridLayout.addWidget(self.plainTextEdit, 0, 0, 1, 1)
> MainWindow.setCentralWidget(self, self.centralwidget)
> self.statusBar()
> menubar = self.menuBar()
> file = menubar.addMenu('&File')
> file.addAction(exit)
>
> sayHiAction =
> QtGui.QAction(QtGui.QIcon('icons/address-book-new.png'),
> 'Greet them!', self)
> sayHiAction.setStatusTip('Say Hi')
> toolBar.addAction(sayHiAction)
> file.addAction(sayHiAction)
> sayHiAction.triggered.connect(self.sayHi)
>
> def sayHi(self):
> self.plainTextEdit.setPlainText('Hi Pete, hi world!')
> # setPlainText(text) first clears the plainTextEdit window.
> self.plainTextEdit.appendPlainText('Peace to people of good will!')
>
> app = QtGui.QApplication(sys.argv)
> main = MainWindow()
> main.show()
> sys.exit(app.exec_())
>
> Thanks to Pete for showing the simpler nes style of signal/slot connection!
>
> Kind regards,
> OldAl
>
-----------------------------------------
More information about the PyQt
mailing list