[PyQt] Working example of QMenuBar on OSX? Examples don't work

David Cortesi davecortesi at gmail.com
Sun Jun 5 17:42:49 BST 2016


I have a PyQt5 app that works well in Mac OS, Linux and Windows. The only
difference I see in the setup of my QMainWindow is this:

        import platform
        if platform.uname().system.startswith('Darw') :
            self._menu_bar = QMenuBar() # parentless menu bar for Mac OS
        else :
            self._menu_bar = self.menuBar() # refer to the default one

and then it proceeds to initialize self._menu_bar with menus, e.g.

        self.file_menu = self._menu_bar.addMenu(_TR('Menu name', '&File'))
        work = self.file_menu.addAction( _TR('File menu command','&New') )
        work.setShortcut(QKeySequence.New)
        work.setToolTip( _TR('File:New tooltip','Create a new, empty
document') )
        work.triggered.connect(self._new)

and so forth. The above test of platform.uname() is about the only platform
difference in the whole app...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160605/a0fcf3a8/attachment.html>


More information about the PyQt mailing list