我想更改应用程序图标的悬停标题;这样,在下图中,它读作“FOO”而不是“python”。我正在展示我用来导入应用程序图标的代码,我在想是否有办法,它必须是在它下面的一个衬里。有人知道吗?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_())图片:
1 回答
红糖糍粑
TA贡献1815条经验 获得超6个赞
尝试按如下方式设置应用程序名称:
QCoreApplication.setApplicationName('FOO')
您还可以为窗口添加标题,例如:
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_())
添加回答
举报
0/150
提交
取消