Reputation: 454
I'm writing a GUI application using Python and Qt. In this application I want to "decorate" dialogs and output data with theme icons like document-open
or dialog-error
. This is easily retrieved with a statement like:
from PyQt5.QtGui import QIcon
…
… = QIcon.fromTheme("dialog-error")
The exact icon to retrieve is designated by an index into a list, which results in the following code:
DECORATION = [ None, "dialog-error", "document-open", "app-specific" ]
…
… = QIcon.fromTheme(DECORATION[i])
I'd like "app-specific" to point to some user directory acting like an addition to the current theme, in order to manage theme- and user-icons in the same statement.
Presently, I have given this user-directory the same structure as /usr/share/ with icons/ and applications/ subdirectories. In icons/, there is a hicolor/ directory containing the "size" subdirs and actions/ with my additional icons.
I already added in the application main window initialisation:
def __init__(self):
…
searchPath = QIcon.themeSearchPaths()
searchPath.insert(0, XDG_DIR)
QIcon.setThemeSearchPaths(searchPath)
…
where XDG_DIR
is a string containing the absolute path to my icons/ directory.
This doesn't work. I correctly retrieve the "standard" freedesktop.org icons but not mine.
themeSearchPaths
be done before initialising the application (and Qt)?I don't want to create a system-wide theme. I only want the patch to be effective during application execution so that other applications are not polluted.
Upvotes: 0
Views: 224