How to set system tray title when hovering over app icon
Question:
I’d like to change the hover-over title of my app icon; such that, in the picture below, it reads “FOO” instead of “python”. I’m showing the code I’ve used to import the app icon, and am thinking if there’s a way, it must be a one liner underneath this. Anyone know?
if __name__ == '__main__':
app = QtGui.QApplication.instance()
if app is None:
app = QtGui.QApplication([])
# set app icon for tray:
pyDir = os.path.dirname(os.path.abspath(__file__)) #python file location
iconDir = os.path.join(pyDir, 'icons')
app_icon = QtGui.QIcon()
app_icon.addFile(os.path.join(iconDir, '256x256.png'), QtCore.QSize(256,256))
app.setWindowIcon(app_icon)
#should be a one-liner here?? app.setWindowIconTitle, etc?
w = MainWindow()
sys.exit(app.exec_())
Image:
Answers:
Try by setting the app name as follows:
QCoreApplication.setApplicationName('FOO')
You can also add a title to your window, e.g.:
import sys
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
if __name__ == '__main__':
app = QApplication([])
# set app icon for tray:
pyDir = os.path.dirname(os.path.abspath(__file__))
iconDir = os.path.join(pyDir, 'icons')
app_icon = QtGui.QIcon()
app_icon.addFile(os.path.join(iconDir, '256x256.png'), QtCore.QSize(256,256))
app.setWindowIcon(app_icon)
w = QMainWindow()
w.setWindowTitle("FOO")
w.show()
sys.exit(app.exec_())
I’d like to change the hover-over title of my app icon; such that, in the picture below, it reads “FOO” instead of “python”. I’m showing the code I’ve used to import the app icon, and am thinking if there’s a way, it must be a one liner underneath this. Anyone know?
if __name__ == '__main__':
app = QtGui.QApplication.instance()
if app is None:
app = QtGui.QApplication([])
# set app icon for tray:
pyDir = os.path.dirname(os.path.abspath(__file__)) #python file location
iconDir = os.path.join(pyDir, 'icons')
app_icon = QtGui.QIcon()
app_icon.addFile(os.path.join(iconDir, '256x256.png'), QtCore.QSize(256,256))
app.setWindowIcon(app_icon)
#should be a one-liner here?? app.setWindowIconTitle, etc?
w = MainWindow()
sys.exit(app.exec_())
Image:
Try by setting the app name as follows:
QCoreApplication.setApplicationName('FOO')
You can also add a title to your window, e.g.:
import sys
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
if __name__ == '__main__':
app = QApplication([])
# set app icon for tray:
pyDir = os.path.dirname(os.path.abspath(__file__))
iconDir = os.path.join(pyDir, 'icons')
app_icon = QtGui.QIcon()
app_icon.addFile(os.path.join(iconDir, '256x256.png'), QtCore.QSize(256,256))
app.setWindowIcon(app_icon)
w = QMainWindow()
w.setWindowTitle("FOO")
w.show()
sys.exit(app.exec_())