Manage QIcon instances on a application global level

c.buhtz at posteo.jp c.buhtz at posteo.jp
Thu Jul 6 11:15:27 BST 2023


Hello,

I do use PyQt5.

I have a module "icon.py" in my application containing lines with 
constants like this:

     PAUSE = QIcon.fromTheme('media-playback-pause')

Somewhere else in my application I do use "icon.PAUSE". But before doing 
this I have to "import icon" of course.

The problem is that I'm not able to put the import statement in the 
beginning of the py files like you usually do it with imports. I have to 
put it e.g. in the __init__() method of my QMainWindow derived classed 
and after QApplication() was instanciated. I understand why it is that 
way.

But maybe you can explain how you do manage icons in your application?

Kind
Christian


More information about the PyQt mailing list