不显示图标 [英] does not show icons

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

问题描述

我刚刚安装了 Python3 (3.5.2) 和 Pyqt5 (5.8.2),我正在按照本教程学习和制作 GUI:

解决方案

请注意,您根本没有所有应用程序的图标,而不仅仅是 PyQt 图标示例.这是因为默认情况下,某些环境会关闭标题栏中的图标.您必须启用它们.

例如在 Xfce 桌面环境中,我们可以使用 xfce4-settings-editor 工具.在设置/设置编辑器中选择 xfwm4.找到 show_app_icon 选项并检查它.来回更改主题以查看更改;它们不会立即可见.

此后,您将在 PyQt5 示例的标题栏中看到该图标.

至于警告;这是最近的事情,它必须做点什么Qt 和 GTK 主题之间的不兼容.我还没发现到目前为止删除警告的解决方案.

I just installed Python3 (3.5.2) and Pyqt5 (5.8.2) and I am following this tutorial to learn and make a GUI: http://zetcode.com/gui/pyqt5/firstprograms/

I'm trying to run the 2nd example but program is returning an error (which also happened on the 1st one, but since it had no image i took no notice) which is the following:

QApplication: invalid style override passed, ignoring it.
No XVisualInfo for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(SingleBuffer), swapInterval 1, profile  QSurfaceFormat::OpenGLContextProfile(NoProfile))
Falling back to using screens root_visual.

What is the meaning of this? Am i missing some packages?

I installed pyqt first with this command:

sudo -H pip3 install PyQt5

but Python3 was not acknowledging its existence so i searched the apt ubuntu repos and installed with:

sudo apt install python3-PyQt5

I also tried to reference the image by full path /foo/bar/image.png and nothing

What is the problem?

EDIT #1

The code that i am using is from example 2:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
ZetCode PyQt5 tutorial

This example shows an icon
in the titlebar of the window.

author: Jan Bodnar
website: zetcode.com
last edited: January 2015
"""

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

base_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(base_dir)

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('image.png'))

        self.show()


if __name__ == '__main__':

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

After your post i reinstalled all my packages. The error is slightly different but the result is the same:

python3 example_02.py 
QApplication: invalid style override passed, ignoring it.

Screencapture:

解决方案

Notice that you are having no icons at all for all applications, not just for the PyQt icon example. This is because by default, certain environments turn off the icons in the titlebar. You have to enable them.

For instance in Xfce Desktop Environment, we can use the xfce4-settings-editor tool. In Settings/Settings Editor select xfwm4. Find the show_app_icon option and check it. Change a theme back and forth to see the changes; they are not visible right away.

After this, you will see the icon in the titlebar of the PyQt5 example.

As for the warning; it is a recent thing and it has to do something with the incopatibilities between Qt and GTK theming. I have not found a solution to remove the warning so far.

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

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