2017-05-24 10 views
0

は私から1つのアイコンを使用しようとしました:Python Qt4ウィンドウアイコンを設定するには?

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

しかし、それは、ウィンドウの上に表示されません。

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午前したWindows 10上: - >conda 4.3.18

  • パイソンpython --version -

    1. アナコンダconda --version>Python 2.7.13 :: Anaconda custom (32-bit)
  • 答えて

    1

    documentationはデフォルトで

    を言う、唯一のX11は、テーマのアイコンをサポートしています。 MacおよびWindowsでテーマアイコンを使用するには、themeSearchPaths()のいずれかに準拠したテーマをバンドルし、適切なthemeName()を設定する必要があります。
    この関数はQt 4.6で導入されました。

    テーマを収集してアプリケーションに同梱する必要があるため、アイコンをいくつか収集して直接指定することもできます。

    w.setWindowIcon(QtGui.QIcon("folder.png")) 
    
    +0

    「準拠するテーマ」をバンドルするにはどうすればよいですか? – user

    +0

    私は分かりませんが、あなたがそれをしていないことは明らかです。 ;-) – ImportanceOfBeingErnest

    +1

    質問https://stackoverflow.com/questions/29392213/what-path-to-enter-in-pyqt-qicon-setthemesearchpaths-in-pyqt-on-win7助けているようです。 – user

    関連する問題