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

MNT: remove widget classes inheritance from enum, as preperation for qt6 enum support #1154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nstelter-slac
Copy link
Collaborator

@nstelter-slac nstelter-slac commented Jan 11, 2025

This should fix main issue making it difficult to support both PyQt5 and PySide6 enums at same time!

The need for inheritance was b/c when an enum gets written to a ui file by designer, its in the form of <widget class name>::<enum value> (ex='PyDMLabel::STRING').

On loading the ui file, unless the widget class had subclassed the enum class it wouldn't find the definition of the enum.

The issue with subclassing the enum is: in qt6 enums must inherit from python 'Enum' (ex = class MyNewEnum(Enum)), and these classes can not be inherited from.

So instead we can just re-declare the values of the enum in the class itself, mimicking if the class had inherited from the enum.

@nstelter-slac nstelter-slac force-pushed the remove_enum_inheritence branch 3 times, most recently from ef1d75a to 8a963e8 Compare January 11, 2025 02:14
…t6 enum support

The need for inheritance was b/c  when an enum gets written to a ui file by
designer, its in the form of <widget class name>::<enum value> (ex='PyDMLabel::STRING').

On loading the ui file, unless the widget class had subclassed the enum class it
would not be able to find the definition of the enum.

The issue with subclassing the enum is:  in qt6 enums must inherit
from python Enum (ex = class MyNewEnum(Enum)), and these classes can not be
inherited from.

So instead of inheriting the enum we can just re-declare the values of the enum
in the class itself.
@nstelter-slac nstelter-slac force-pushed the remove_enum_inheritence branch from 8a963e8 to 9b8866d Compare January 11, 2025 02:18
@nstelter-slac
Copy link
Collaborator Author

nstelter-slac commented Jan 11, 2025

also did some manual testing:
-opened changed widgets in designer, no error output related to enums
-opened changed widgets with pydm, loaded with no issue or error output
-opened changed widgets in designer, changed enum value and saved, then opened again with pydm with no issues

@nstelter-slac nstelter-slac changed the title MNT: remove widget classes inheriting from enum, as preperation for qt6 enum support MNT: remove widget classes inheritence from enum, as preperation for qt6 enum support Jan 11, 2025
@nstelter-slac nstelter-slac changed the title MNT: remove widget classes inheritence from enum, as preperation for qt6 enum support MNT: remove widget classes inheritance from enum, as preperation for qt6 enum support Jan 11, 2025
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

Successfully merging this pull request may close these issues.

1 participant