Question

I simply want to create a digital clock which displays the current time in the system tray.

I can draw an icon using QPainter and set it to the QSystemTrayIcon object, but the icon is always sized to 22x22 pixels.

How can I achieve this, I know that PyGTK can simply add a label to the tray icon object, what is the solution for PyQT/PySide ?

Was it helpful?

Solution

"Icon was resized to 22x22 pixels", I will assume that you are running your application on X11-based system (Ubuntu or other linux distribution.)

In QSystemTrayIcon doc, it says that your icon will be resized according to OS you use:

On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary

You can still workaround this by:

  1. Create two 22x22 system tray icons with QPainter: one for hours, and another for minutes
  2. Show two system tray icons (Hours on the left, minute on the right)

This workaround is prone to error, because icons may be shown in the wrong order. If X11 is your only target platform, I would strongly recommend you to use pygtk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top