【发布时间】:2014-02-15 11:13:30
【问题描述】:
我不明白为什么我的窗口上绝对没有显示图标。该图标与 python 脚本位于同一目录中。
import sys
from PyQt4 import QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Icon_test')
self.setWindowIcon(QtGui.QIcon('application-icon.png'))
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
非常感谢任何帮助!
【问题讨论】:
-
相对路径才能起作用,它必须是相对于当前目录的,它不一定与python脚本所在的目录相同。
标签: python python-2.7 icons pyqt pyqt4