Mike
Mike

Reputation: 1273

How to create a menu bar on OSX with PySide2?

I'm looking at the Data Visualization Tool Tutorial on the QT website where they have an example of creating a menu bar inside a QMainWindow:

self.menu = self.menuBar()
self.file_menu = self.menu.addMenu("File")

This doesn't work for me on OSX 10.13.6. I've also tried using QMenuBar to create my own menu bar rather than using the default one that comes with a QMainWindow:

menu_bar = QMenuBar()
menu_bar.addMenu('File')
self.setMenuBar(menu_bar)

This also has no effect. I never see the "File" option in the menu bar of my app. I just get a generic menu bar with a single "python" option.

Upvotes: 1

Views: 860

Answers (1)

alec
alec

Reputation: 6112

I believe it is working, but "File" will only appear once you add actions to the file menu.

menu = self.menuBar()
file = menu.addMenu('File')
file.addAction(QAction('Open...', self))

Upvotes: 6

Related Questions