<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">QIcon can be drawn in disabled or selected mode which depends on the application style, <br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">which is why it requires an active qguipplication instance.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">You can simply create qapplication instance in your application __init__.py, or make icon.py lazy, e.g.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">from PyQt5.QtGui import QIcon<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">ICONS = {'PAUSE': 'media-playback-pause'}<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">def __getattr__(name):</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"> return globals().setdefault(name, QIcon.fromTheme(ICONS[name]))<br></div></div><div dir="ltr"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 6, 2023 at 5:15 PM <<a href="mailto:c.buhtz@posteo.jp" target="_blank">c.buhtz@posteo.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
I do use PyQt5.<br>
<br>
I have a module "icon.py" in my application containing lines with <br>
constants like this:<br>
<br>
PAUSE = QIcon.fromTheme('media-playback-pause')<br>
<br>
Somewhere else in my application I do use "icon.PAUSE". But before doing <br>
this I have to "import icon" of course.<br>
<br>
The problem is that I'm not able to put the import statement in the <br>
beginning of the py files like you usually do it with imports. I have to <br>
put it e.g. in the __init__() method of my QMainWindow derived classed <br>
and after QApplication() was instanciated. I understand why it is that <br>
way.<br>
<br>
But maybe you can explain how you do manage icons in your application?<br>
<br>
Kind<br>
Christian<br>
</blockquote></div></div>
</div>