user1225905
user1225905

Reputation: 95

PyQT5 menu not visible

When executing this little PyQT5 script, I can't see the menu; it just displays an empty window (no errors or warnings) on ubuntu 14.04.

from PyQt5 import QtWidgets

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(MainWindow,self).__init__()
        self.createUI()

    def doAction(self):
        print('action')

    def createUI(self):
        self.setWindowTitle('Test')
        menu   = self.menuBar().addMenu('File')
        action = menu.addAction('Action')
        action.triggered.connect(self.doAction)   


if __name__ == '__main__':

    import sys
    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()
    window.show()
    window.setGeometry(400, 200, 200, 200)
    sys.exit(app.exec_())

Any ideas?

Upvotes: 0

Views: 2209

Answers (1)

mrprfrm
mrprfrm

Reputation: 106

I had the same problem Try to set native menu bar flag as false like this:

menu.setNativeMenuBar(False)

Upvotes: 8

Related Questions