0

I tried to use one icon from:

  1. https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
  2. PyQt4 set windows taskbar icon

But it does not show up on the window:

enter image description here

#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
import sys
from PyQt4.QtGui import *

# Create an PyQT4 application object.
a = QApplication(sys.argv)

# The QWidget widget is the base class of all user interface objects in PyQt4.
w = QWidget()

# Set window size.
w.resize(820, 240)

# Set window title
w.setWindowTitle("Hello World!")

# https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
undoicon = QIcon.fromTheme("camera-web")
w.setWindowIcon(undoicon)

# Show window
w.show()

sys.exit(a.exec_())

I am on Windows 10 with:

  1. Anaconda conda --version -> conda 4.3.18
  2. Python python --version -> Python 2.7.13 :: Anaconda custom (32-bit)
user
  • 5,816
  • 7
  • 53
  • 105

1 Answers1

1

The documentation says

By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your themeSearchPaths() and set the appropriate themeName().
This function was introduced in Qt 4.6.

Since you would need to gather a theme anyways to ship with the application, you could also just choose to collect some icons and specify the files directly.

w.setWindowIcon( QtGui.QIcon("folder.png") )
ImportanceOfBeingErnest
  • 251,038
  • 37
  • 461
  • 518