窗口图标不显示 [英] Window icon does not show

查看:283
本文介绍了窗口图标不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了本教程 http://zetcode.com/gui/pyqt5/firstprograms/ 并在这里编码.

I study this tutorial http://zetcode.com/gui/pyqt5/firstprograms/ and code here.

import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon


class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()


    def initUI(self):

        self.setGeometry(300, 300, 300, 220)
        self.setWindowTitle('Icon')
        self.setWindowIcon(QIcon('web.png'))        

        self.show()


if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())  

我可以显示窗口"图标吗?我使用PyQt5,Python3.4和Linuxmint 17.2肉桂.

Can I show Window icon? I use PyQt5, Python3.4 and Linuxmint 17.2 cinnamon.

推荐答案

我不确定您的期望是什么: windowicon显示为applicationIcon(例如,在ubuntu gnome上,请在后台查看我的代码)

i am not sure, what you expected: the windowicon is shown as applicationIcon (e.g. here on ubuntu gnome, see my code in the background)

如果未设置任何图标,则windowIcon()返回应用程序图标

If no icon has been set, windowIcon() returns the application icon

(QApplication :: windowIcon()).

(QApplication::windowIcon()).

http://doc.qt.io/qt-5 /qwidget.html#windowIcon-prop

在ubuntu上看起来像这样:

looks on ubuntu like this:

所以我认为代码可以正常工作

so i think, the code is working correctly

这篇关于窗口图标不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆