[python]pyqt5 framework: Menu bar not visible

I was learning graphical programming with python, and found that my menu bar did not appear on the main window.

This is resolved by putting this menu_bar.setNativeMenuBar(False), see this reference: https://stackoverflow.com/questions/30325026/pyqt5-menu-not-visible, see solution provided by Marble.

This is the sample code, I added the above line:

import sys
from PyQt5.QtWidgets import QApplication,QMainWindow, QAction

class GUI(QMainWindow):
    def __init__(self):

        super().__init__() # inherit from QMainWindow

    def initUI(self):
        self.setWindowTitle("PyQT5 title")

        menu_bar = self.menuBar()
        file_menu = menu_bar.addMenu('File')
        edit_menu = menu_bar.addMenu('Edit')
        new_action = QAction('New',self)
        new_action.setStatusTip("New File")

        self.resize(400, 300)
        self.statusBar().showMessage("Text in status bar")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    gui = GUI()
This entry was posted in Python, Scripting and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s