Reputation: 15
I was using Python 3.7.9 with PyQt5 and I was able to leverage the QSystemTrayIcon to display the Information icon without issue.
This is what the system message displays when using PyQt5.
I recently upgraded to 3.11.1 and since I was redownloading several packages, I decided to upgrade to PyQt6. The vast majority of my code was fine, but when I'm trying to display the system's Information icon, I get the following error:
Traceback (most recent call last):
File "path to python program", line 232, in closeEvent
self.tray_icon.showMessage("Tray Program", "Application was minimized to Tray", QSystemTrayIcon.Information, 2000)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'QSystemTrayIcon' has no attribute 'Information'
The code that calls it is fairly straightforward:
def closeEvent(self, event):
event.ignore()
self.hide()
self.tray_icon.showMessage("Tray Program", "Application was minimized to Tray", QSystemTrayIcon.Information, 2000)
I haven't been able to find anything different in the Qt6 documentation stating that the usage of QSystemTrayIcon.Information has changed. Any help on getting the Information system icon to come up with this message would be appreciated!
Upvotes: 0
Views: 404
Reputation: 593
As @musicamante said in the comments, all enum members must be named using their fully qualified names. And this applies to all enums and flags including those in the QtCore.Qt
namespace.
I recommend you to check this website where you can find very well documented differences between PyQt5 and PyQt6, an example not only for your problem but also for other changes.
Upvotes: 3