I've been hobby writing a little budget tool for myself over the last few months, and have finally gotten some ok functionality. Decided to polish it a bit and make it act more like a GUI app.
Running Python 3.13.7, and PyQt6 6.6.0.
It was going fine until I tried to give some menuBar functionality. The menubar finally shows my app's name, and has the options I was trying to set, but when I actually try to interact with the bar, I get an app crash and this output:
zsh: bus error python3
I did some searching and made sure that all packages are the ARM64 variety, but cannot figure out what else could be causing this. Any ideas?
Code for launching the app window is pasted below.
main.py
if __name__ == '__main__':
if platform.system() == "Darwin":
# Make sure to allow native menu bar BEFORE QApplication is created
QApplication.setAttribute(Qt.ApplicationAttribute.AA_DontUseNativeMenuBar, False)
app = QApplication(sys.argv)
app.setOrganizationName("<name_redacted>")
app.setApplicationName("<name_redacted>")
app.setApplicationDisplayName("<name_redacted>")
app.setApplicationVersion("0.0")
window = mv.MainWindow()
# ---- macOS: NSApplication is created ----
if platform.system() == "Darwin":
try:
import AppKit, objc
bundle = AppKit.NSBundle.mainBundle()
if bundle:
bundle.infoDictionary()["CFBundleName"] = "<name_redacted>"
else:
print("No main bundle found; skipping CFBundleName rename")
except Exception as e:
print("Could not set macOS app name:", e)
window.show()
sys.exit(app.exec())
mainView.py
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.vm = ViewModel()
self.setWindowTitle("<name_redacted>")
self.setMinimumSize(QSize(vc.APPWIDTH, vc.APPHEIGHT))
# Central widget
central_widget = QWidget()
self.setCentralWidget(central_widget)
# Compose layout using small "builder" methods
layout = QVBoxLayout()
layout.addLayout(self.build_buttons_row())
layout.addWidget(CategoryTreeView(self.vm))
central_widget.setLayout(layout)
#Create menubar
self.create_menus()
def create_menus(self):
menubar = self.menuBar()
# --- File ---
file_menu = menubar.addMenu("&File")
quit_action = QAction("&Quit", self)
quit_action.setShortcut("Ctrl+Q")
quit_action.setStatusTip("Exit the application")
quit_action.triggered.connect(QApplication.instance().quit)
quit_action.setMenuRole(QAction.MenuRole.QuitRole)
file_menu.addAction(quit_action)
# --- Edit ---
edit_menu = menubar.addMenu("&Edit")
preferences_action = QAction("&Preferences...", self)
preferences_action.triggered.connect(self.open_preferences)
edit_menu.addAction(preferences_action)
edit_menu.addSeparator()
edit_menu.addAction("Cut")
edit_menu.addAction("Copy")
edit_menu.addAction("Paste")
# --- Help ---
help_menu = menubar.addMenu("&Help")
about_action = QAction("&About MyApp", self)
about_action.triggered.connect(self.show_about)
about_action.setMenuRole(QAction.MenuRole.AboutRole)
help_menu.addAction(about_action)
#MenuBar items
def open_preferences(self):
QMessageBox.information(self, "Settings", "Settings open")
def show_about(self):
QMessageBox.information(self, "About", "About MyApp")
AA_DontUseNativeMenuBarpart (which seems unnecessary, as menu bars should be native by default on macOS AFAIK) and/or the whole bundle checking. Finally, include the specific versions of both your OS and Qt (not just PyQt, as their version numbers don't match).