Hi,

I'm trying to teach myself GUI programmming with the help of the new 
PyQt book and the examples from the PyQt package. Although I've been 
doing Python for five years I have a hard time doing OOP stuff. 
Frankly, I never know when and where to put this "self" thing.

My script (see below) works (no wonder, it's cut down from the 
application.pyw example). But as soon as I wanted to add a help action 
it doesn't work. The help action is ripped from Mark Summerfield's 
sandbox.pyw and calculate.pyw.

Can anyone help me with the help function?!

##
#! /usr/bin/env python

import sys
from PyQt4 import QtGui, \
                  QtCore

class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        # create actions
        self.aboutAct = QtGui.QAction(self.tr('&About'), self)
        self.aboutAct.setStatusTip(self.tr('Show the application\'s About box'))
        self.connect(self.aboutAct, QtCore.SIGNAL('triggered()'), self.about)

        self.helpAct = QtGui.QAction(self.tr('&Help'), self)
        self.helpAct.setStatusTip(self.tr('Online help'))
        self.connect(self.helpAct, QtCore.SIGNAL('triggered()'), self.help)

        # create menus
        self.helpMenu = self.menuBar().addMenu(self.tr('&Help'))
        self.helpMenu.addAction(self.helpAct)
        self.helpMenu.addAction(self.aboutAct)

        # create status bar
        self.statusBar().showMessage(self.tr('Ready'))

    def about(self):
        QtGui.QMessageBox.about(self, self.tr('About Application'),
                                      self.tr('Application does something\n'
                                              'This software comes without 
warranty, liability or support!'))

    def help(self):
        browser = QtGui.QTextBrowser()
        browser.append('Help')
        layout = QtGui.QVBoxLayout()
        layout.addWidget(browser)

app     = QtGui.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
app.exec_()
##

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to