-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #929 from PrimozGodec/pyqt6-compat
[FIX] Make widgets PyQt6 compatible
- Loading branch information
Showing
5 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
from enum import IntEnum, Enum | ||
from typing import Union | ||
|
||
from .decorators import * | ||
from .widgets import * | ||
from .concurrent import asynchronous | ||
|
||
|
||
def enum2int(enum: Union[Enum, IntEnum]) -> int: | ||
""" | ||
PyQt5 uses IntEnum like object for settings, for example SortOrder while | ||
PyQt6 uses Enum. PyQt5's IntEnum also does not support value attribute. | ||
This function transform both settings objects to int. | ||
Parameters | ||
---------- | ||
enum | ||
IntEnum like object or Enum object with Qt's settings | ||
Returns | ||
------- | ||
Settings transformed to int | ||
""" | ||
return int(enum) if isinstance(enum, int) else enum.value |