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 self.initUI() def initUI(self): self.setWindowTitle("PyQT5 title") menu_bar = self.menuBar() menu_bar.setNativeMenuBar(False) file_menu = menu_bar.addMenu('File') edit_menu = menu_bar.addMenu('Edit') new_action = QAction('New',self) file_menu.addAction(new_action) 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() gui.show() sys.exit(app.exec_())