How does one set an app's About (help) menu to display the app's name, rather than "Python."

In addition, I'd like to have the menu's aboutAction item and the exitAction item display my app name as well. They currently display "About Python" and "Quit Python," respectively.

Interestingly, the aboutQtAction displays the string specified in the QAction declaration.

Is this an OS-specific issue? I'm testing on OSX. See the attached example program, simplified from .../examples/menus.py.

Thanks!
Scott




#!/usr/bin/env python

import sys
from PyQt4 import QtCore, QtGui


class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        
        w = QtGui.QWidget()
        self.setCentralWidget(w)
        
        topFiller = QtGui.QWidget()
        topFiller.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                QtGui.QSizePolicy.Expanding)

        self.infoLabel = QtGui.QLabel(self.tr("<i>see About menu</i>"))

        self.infoLabel.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken)
        self.infoLabel.setAlignment(QtCore.Qt.AlignCenter)
        
        bottomFiller = QtGui.QWidget()
        bottomFiller.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)

        vbox = QtGui.QVBoxLayout()
        vbox.setMargin(5)
        vbox.addWidget(topFiller)
        vbox.addWidget(self.infoLabel)
        vbox.addWidget(bottomFiller)
        w.setLayout(vbox)

        self.createActions()
        self.createMenus()
        
        self.setWindowTitle(self.tr("Menu Test"))
        self.setMinimumSize(160,160)
        self.resize(480,320)
        
    def newFile(self):
        self.infoLabel.setText(self.tr("Invoked <b>File|New</b>"))
            
    def about(self):
        self.infoLabel.setText(self.tr("Invoked <b>Help|About</b>"))
        QtGui.QMessageBox.about(self, self.tr("About Menu"),
                self.tr("The <b>Menu</b> example shows how to create "
                        "menu-bar menus and context menus."))
               
    def aboutQt(self):
        self.infoLabel.setText(self.tr("Invoked <b>Help|About Qt</b>"))
        
    def createActions(self):
        self.newAct = QtGui.QAction(self.tr("&New"), self)
        self.newAct.setShortcut(self.tr("Ctrl+N"))
        self.newAct.setStatusTip(self.tr("Create a new file"))
        self.connect(self.newAct, QtCore.SIGNAL("triggered()"), self.newFile)

        self.exitAct = QtGui.QAction(self.tr("E&xit"), self)
        self.exitAct.setShortcut(self.tr("Ctrl+Q"))
        self.exitAct.setStatusTip(self.tr("Exit the application"))
        self.connect(self.exitAct, QtCore.SIGNAL("triggered()"), self.close)

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

        self.aboutQtAct = QtGui.QAction(self.tr("About &Qt"), self)
        self.aboutQtAct.setStatusTip(self.tr("Show the Qt library's About box"))
        self.connect(self.aboutQtAct, QtCore.SIGNAL("triggered()"), QtGui.qApp.aboutQt)
        self.connect(self.aboutQtAct, QtCore.SIGNAL("triggered()"), self.aboutQt)

    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
        self.fileMenu.addAction(self.newAct)
        self.fileMenu.addAction(self.exitAct)

        self.helpMenu = self.menuBar().addMenu(self.tr("&Help"))
        self.helpMenu.addAction(self.aboutAct)
        self.helpMenu.addAction(self.aboutQtAct)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    mainwindow = MainWindow()
    mainwindow.show()
    sys.exit(app.exec_())


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

Reply via email to