Skip to content

PR: Change access of constants to scoped enum style for PyQt6#179

Closed
kumattau wants to merge 1 commit intospyder-ide:masterfrom
kumattau:pyqt6-scoped-enums
Closed

PR: Change access of constants to scoped enum style for PyQt6#179
kumattau wants to merge 1 commit intospyder-ide:masterfrom
kumattau:pyqt6-scoped-enums

Conversation

@kumattau
Copy link
Contributor

This PR is for changing access of constants to scoped enum style for PyQt6.
(I used spyder-ide/qtpy#233 (comment) 's tools to change)

As spyder-ide/qtpy#233 (comment) says

all bindings from 5.12+ (they may be supported in older versions, I just didn't check) supported the scoped enums

in the case of PyQt 5.9.2 provided by the latest conda,
the constants contained in qtawesome can be accessed via scoped enums.

I think this PR can be merged if support of qtawesome is enough with PyQt 5.9.2 or later.

I tested scoped enums using https://gist.github.com/kumattau/fa9e75b4cea6ec3722d9960f5a3996c9.

At least, the changed code works with pyqt 5.9.7 of conda.
@kumattau
Copy link
Contributor Author

I'm sorry, this change does not work with Python 3.7 or before, but I don't know why...

@dalthviz
Copy link
Member

dalthviz commented Oct 22, 2021

Don't worry @kumattau ! But yes, checking locally with Python 3.7/PyQt 5.9.2 on conda and pip seems like GlobalColor doesn't have the constants for colors :/

Not totally sure what to do, maybe we should update the tests to be run using the conda-forge channel or maybe check this on the QtPy side. What do you think @ccordoba12 ?

@ccordoba12
Copy link
Member

This PR is for changing access of constants to scoped enum style for PyQt6.

Before doing changes here, I think we should decide what to do about this problem on QtPy. This is something @dalthviz and I are discussing and we'd prefer to preserve the way to access enums in PyQt5 to not break current apps (although that's something we'd like to discuss with the rest of the community on issue spyder-ide/qtpy#233).

If we all agree on that, then this PR wouldn't be necessary, I think.

@ccordoba12
Copy link
Member

Not totally sure what to do, maybe we should update the tests to be run using the conda-forge channel or maybe check this on the QtPy side. What do you think @ccordoba12 ?

I'm fine with moving our tests to conda-forge.

@kumattau
Copy link
Contributor Author

kumattau commented Oct 23, 2021

@dalthviz, @ccordoba12, thank you for comment.

I'm sorry, this change does not work with Python 3.7 or before, but I don't know why...

This problem seems to be caused by that sip-4.19.8 in conda Python 3.6 and 3.7 environment is too old to support scoped enum.

sip seems to support scoped enum in version 4.19.9 or later.
https://www.riverbankcomputing.com/hg/sip/rev/79b93109033f

In short, PyQt 5.9 is ready for scoped enum but requires sip 4.19.9 or later for it.

In conda, sip-4.19.13 package is available but the package cannot installed in Python 3.6 or 3.7 environment for the package dependency.

All packages are installed from conda:
[PASS] Python 3.8.12, PyQt 5.9.2, Qt 5.9.7, Sip 4.19.13
[FAIL] Python 3.7.11, PyQt 5.9.2, Qt 5.9.6, Sip 4.19.8
[FAIL] Python 3.6.13, PyQt 5.9.2, Qt 5.9.6, Sip 4.19.8

Overwrite installation of Sip from source:
[PASS] Python 3.7.11, PyQt 5.9.2, Qt 5.9.6, Sip 4.19.13
[PASS] Python 3.6.13, PyQt 5.9.2, Qt 5.9.6, Sip 4.19.13

If we all agree on that, then this PR wouldn't be necessary, I think.

Should I withdraw PR at the moment until the policy is decided ?

@ccordoba12
Copy link
Member

Should I withdraw PR at the moment until the policy is decided ?

No, let's wait until we decide what to do about this issue in QtPy.

@CAM-Gerlach
Copy link
Member

NB, seems like we decided to have QtPy promote scoped to unscoped enums in PyQt6 for compatibility purposes, in spyder-ide/qtpy#271

@kumattau
Copy link
Contributor Author

kumattau commented Nov 9, 2021

Hi @CAM-Gerlach

Thank you for info.
I will close this PR after I check the original qtawesome works with qtpy, which supports PyQt6.

@kumattau
Copy link
Contributor Author

I will close this PR after I check the original qtawesome works with qtpy, which supports PyQt6.

I checked that the original example.py and qtabroswer with the #183 fix work fine with qtpy, which supports PyQt6.
Note that the #183 fix is not directly related to unscoped enums.
So, I close this PR.

@kumattau kumattau closed this Nov 22, 2021
@kumattau kumattau deleted the pyqt6-scoped-enums branch November 22, 2021 17:59
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.

4 participants