Skip to content

Instantly share code, notes, and snippets.

@zas
Created September 13, 2019 09:06
Show Gist options
  • Save zas/3c469b122399abda95c424e1b8ee5498 to your computer and use it in GitHub Desktop.
Save zas/3c469b122399abda95c424e1b8ee5498 to your computer and use it in GitHub Desktop.
from PyQt5.QtCore import QStandardPaths
def get_qt_enum(cls, enum):
d = {}
for key in dir(cls):
value = getattr(cls, key)
if isinstance(value, enum):
d[key] = value
return sorted(d, key=lambda k:d[k])
print(get_qt_enum(QStandardPaths, QStandardPaths.StandardLocation))
@zas
Copy link
Author

zas commented Sep 13, 2019

Output:

['DesktopLocation', 'DocumentsLocation', 'FontsLocation', 'ApplicationsLocation', 'MusicLocation', 'MoviesLocation', 'PicturesLocation', 'TempLocation', 'HomeLocation', 'AppLocalDataLocation', 'DataLocation', 'CacheLocation', 'GenericDataLocation', 'RuntimeLocation', 'ConfigLocation', 'DownloadLocation', 'GenericCacheLocation', 'GenericConfigLocation', 'AppDataLocation', 'AppConfigLocation']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment