Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pya.Application.instance().main_window().menu().insert_menu -- change in behaviour? #1897

Open
lukasc-ubc opened this issue Oct 17, 2024 · 5 comments

Comments

@lukasc-ubc
Copy link

lukasc-ubc commented Oct 17, 2024

Hi Matthias,

I notice that the custom menu I added doesn't show up in the display in the newer version. Is this an intentional change, and is there a way to have it appear like it did in the 0.29.1, as per below?

KLayout 0.29.1 menu bar:
image

KLayout 0.29.6 menu bar:
image

This is implemented using:

pya.Application.instance().main_window().menu().insert_menu("help_menu", "siepic_menu", "SiEPIC 0.5.13 Py3")

I checked the documentation and couldn't find anything suggesting this should not be possible: https://www.klayout.de/doc-qt5/code/class_AbstractMenu.html

Could it be this change? 11139cd

thank you

@Kazzz-S
Copy link
Contributor

Kazzz-S commented Oct 17, 2024

Hello @lukasc-ubc,

The behavior changed in 0.29.2, which is macOS-specific.
gh-1897-01

Document ===> https://www.klayout.de/doc-qt5/about/macro_in_menu.html

gh-1897-02

The report that prompted the fix ===> #1722

@lukasc-ubc
Copy link
Author

Thank you. Given that it worked previously, would there be a way to return that functionality? Or is it a major change in Qt that prevents this moving forward?

@klayoutmatthias
Copy link
Collaborator

Hi @Kazzz-S - thanks for the pointer. I already forgot that issue ...

@lukasc-ubc Problem was that it was possible to add menu items, but when they get removed (which is a valid operation), KLayout crashed on MacOS. The "Extra" menu (with the three dots) as a container for dynamic content was the only feasible solution I found during long debugging sessions via a remote connection. I don't know if it is a Qt bug or some more general limitation, but it appears that it is not possible to dynamically reconfigure the application's top level menu - at least when it comes to removing items.

Matthias

@lukasc-ubc
Copy link
Author

lukasc-ubc commented Oct 19, 2024 via email

@klayoutmatthias
Copy link
Collaborator

There are actually a number of practical issues. Thing is, dynamic menus work perfectly fine on other platforms, so this feature is being used.

I really spent a lot of time trying to bring the behavior to MacOS including attempts to disable them instead of removing them. I could not get it stable.

Menus are dynamic not only because they are explicitly removed, but also when you remove macros or change a macro's menu binding for.example. So it's not enough to simply disable "remove".

Maybe someone with a deeper insight into.Qt's MacOS binding than me could take a look. If there is a way to bring the original behavior to MacOS in a stable way, I'll be happy to adopt that solution.

Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants