r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.77k stars 555 forks source link

[MacOS] Menu example does not show menus #1534

Open mikeylemmon opened 20 hours ago

mikeylemmon commented 20 hours ago

Specification

Description

Menus don't currently seem to be working on MacOS — running the menu example results only in a "View" menu (shown below) regardless of what is passed to the menu argument:

image

This behavior is the same when bundled with py2app.

A tiny bit of digging reveals that the issue can be fixed by commenting out the self._clear_main_menu() call that was added to cocoa.py's first_show method in #1407, but I'm guessing that removing the call also re-introduce the "ever-growing main menu bug". @lanzz were custom menus working when you first implemented your fix for the menu bug?

Practicalities

lanzz commented 12 hours ago

I haven't used custom menus myself, the growing main menu bug I encountered during running the tests for an unrelated change. Sounds like that whole reset menu logic there needs to be moved to the same location where the custom menu is applied.

r0x0r commented 9 hours ago

Yes, @mikeylemmon is correct that _clear_main_menu is the culprit. The menu logic needs to be refactored. Maybe window specific menu can be incorporated as part of this refactor as well