2017-05-24 1 views
0

나는에서 하나 개의 아이콘을 사용하려고 :파이썬 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 오전 윈도우 10과 :

  1. 아나콘다 conda --version ->
  2. conda 4.3.18 파이썬 python --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

관련 문제