Monday, 11 January 2021

pyqt5 default native menu text on MacOS

Is there a way to change default menu title for native menu on MacOS for a simple pyqt5 app?

enter image description here

I'm trying to change "Python" menu entry on above image. Is there a way to rename it? Can I hide it somehow?

This code prints only "File":

menubar = self.menuBar()
for item in menubar.actions():
    print(item.text())

menubar.setNativeMenuBar(False) doesn't help too (just move "File" into the MainWindow).

Update Sample app code:

from PyQt5 import QtCore, QtWidgets, uic
import sys


class Ui(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()
        # QtCore.QCoreApplication.setApplicationName('QtFoo') # doesn't work
        uic.loadUi('App.ui', self)
        self.show()

# app = QtWidgets.QApplication(sys.argv)
app = QtWidgets.QApplication(["MyCoolApp"])
# app.setApplicationName("QtFoo") # doesn't work
# app.setApplicationDisplayName("Display Name")
window = Ui()
app.exec()


from pyqt5 default native menu text on MacOS

No comments:

Post a Comment