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.
RunningPython 3.13.7, andPyQt6 6.6.0.
It was going fine until I tried to give somemenuBar 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 python3I 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")- What do you exactly mean by "interact with the bar"? Also, unless you already did it, can you try to run the code in a terminal and see if it provides more debug output?musicamante– musicamante2025-11-08 03:21:35 +00:00CommentedNov 8 at 3:21
- When I try to use any of the options in the menu bar. I can do anything else in my gui, but when I try to click something in the menu bar, it crashes. Also, the output is exactly the same in pycharm and terminalzoagold– zoagold2025-11-08 17:31:22 +00:00CommentedNov 8 at 17:31
- Sorry, but it's still unclear: are you saying that the crash happens if you click on the "File"/"Edit"/"Help" in the menu bar, or if you click an action in one of those menus? You should also try to exclude as much as possible in order to narrow down the possible causes: try to remove the
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).musicamante– musicamante2025-11-09 03:36:21 +00:00CommentedNov 9 at 3:36 - As far as I know, you can't directly bind a CFBundle to a PyQt application instance in code. However, you can assign a Bundle in the Info.plist file. Try passing os.environ['CFBundleName'] = 'bundle'Алексндр Босов– Алексндр Босов2025-11-10 14:47:58 +00:00CommentedNov 10 at 14:47
