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

Maybe move to Qt.py as a Qt Shim #46

Closed
nebukadhezer opened this issue Jul 7, 2023 · 8 comments
Closed

Maybe move to Qt.py as a Qt Shim #46

nebukadhezer opened this issue Jul 7, 2023 · 8 comments

Comments

@nebukadhezer
Copy link

Hey @hannesdelbeke

I really like all your repos, I was wondering if you would consider a PR moving unimenu to Qt.py ?
https://github.com/mottosso/Qt.py

And in Appdetect instead of importing running for
sys.executable would be faster... I could also prep a PR for that..
But wanted to know if these would be welcome changes or not ?

Let me know what you think

@hannesdelbeke
Copy link
Owner

hannesdelbeke commented Jul 8, 2023

Hi, sounds interesting, Always interested in seeing a better way.

I'm familiar with qt.py, used it a lot myself in the past.
What problem do you want to solve if we used qt.py instead of the current qt implementation? Does unimenu not work correctly in your current setup?

I'm not following exactly what you mean with the app detect and sys.executable. can you rxplain a bit more or perhaps dhow that PR.
Note that sys.exec does not always behave as expected in all apps. E.g. in old blender versions it did not return the blender python interpreter path AFAIK

@hannesdelbeke
Copy link
Owner

And for app detect if optimization is needed we can also always swap to importlib instead of attempt an import. Checking the package name. Its a lot faster but a bit more code

@nebukadhezer
Copy link
Author

Hey,

ok I thought that sys.executable would be reliable. I just guess the more dccs are supported then the check can become longer and longer if it actually tries to import all packages...
I would implement sys.executable for the dccs where it is working... and switch to importlib where it is not reliable.
Though I am thinking if sometimes we might up in environments, where modules are available from other dccs...

For the qt.py switch it is not needed at all... I guess all can stay as it is... again this moves the try except loop into a onetime action.
And not in every file. so it should save time.
But qt.py has no Qt6 support yet so that would be another endeavour. Though there is a PR that works for me, for qt6 support for qt.py. But Marcus has not merged that ...

I tried unimenu last week on friday and I am not sure I am using it wrong, but for maya to correctly be detected I had to modify the NON_QT list and add MAYA there, otherwise it was throwing errors.

I only tried the code sample.

I could rework app detect to sys.executable where I know it should work and then I could make a PR to use it as a dependecy for unimenu?!

We use REZ as a package manager so getting all in via PIP is easy.

Cheers
Johannes

@hannesdelbeke
Copy link
Owner

hannesdelbeke commented Jul 10, 2023

Can you let me know which code you rsted in maya? Adding MAYA will use the old maya unimenu, instead of the new and easier to maintain qt maya menu setup. Both work but new one also has more features i believe. The test code migt need updating. If not it's a bug

@hannesdelbeke
Copy link
Owner

Can you make a pr for the sys exec. But just for 1 app? To see how you have it in mind. Maybe maya or blender?

@nebukadhezer
Copy link
Author

nebukadhezer commented Jul 10, 2023

import unimenu
menu = unimenu.Node(label="my menu")  # create a menu
item = unimenu.Node(label="hi", command='print("hi")')  # create a menu item
menu.items.append(item)  # add the item to the menu
menu.setup()  # setup the menu in the app, parented by default to the main menu bar

produces this in Maya 2022.

Errror: 'NoneType' object has no attribute 'findChild'
Traceback (most recent call last):
File "", line 5, in
File "c:\users\johannes\packages\unimenu\0.4.1\88a70aca30cb79a278872594adf043dc6c40af99\python\unimenu\apps_abstract.py", line 205, in setup
parent_app_node = parent_app_node or self._default_root_parent File "c:\users\johannes\packages\unimenu\0.4.1\88a70aca30cb79a278872594adf043dc6c40af99\python\unimenu\apps\qt.py", line 48, in _default_root_parent
menu_bar = main_window.findChild(QtWidgets.QMenuBar)
AttributeError: 'NoneType' object has no attribute 'findChild' #

@nebukadhezer
Copy link
Author

hannesdelbeke/detect-app#3

Here is the sample pr how I would implement the app detection for dccs where it is possible

@hannesdelbeke
Copy link
Owner

hannesdelbeke commented Jul 19, 2023

since this issue is startign to contain several topics, i will close it and split it up

  • i moved the maya sample to a new issue maya sample errors #52 and will investegate
  • qt.py is not needed for now, closing this issue
  • detect app can be discussed in the detect app repo, or here use detect app dependency #40
    also would be happy to start a detect app PR in unimenu if you want.

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

2 participants