如何从网络加载PyQt4中的.ico文件 [英] How to load .ico files in PyQt4 from network

查看:146
本文介绍了如何从网络加载PyQt4中的.ico文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用PyQt4开发的应用程序.

I have a app developed in PyQt4.

它为Windows和QMenus设置了图标.

It has icons set for windows and QMenus.

所有客户端系统均已安装python.然后从网络位置(\\system_xyz\PyQt4)加载PyQt4.

All client systems have installed python. And PyQt4 is loaded from network location (\\system_xyz\PyQt4).

该应用程序在带有正确加载图标的开发人员系统中可以正常运行. 但是,当在客户端上运行相同的脚本时,应用程序可以运行,但图标不会加载.

The app works fine in developer systems with icons loaded properly. But when the same script is run on clients, app works but icons are not loaded.

在我的应用程序中,我也使用了Qsql驱动程序.它也有同样的问题.在开发人员系统上有效,但在客户端系统上无效.

In my app i used Qsql drivers also. It too had the same issue. works at developer system but not at client system.

我可以通过将sql插件路径添加到以下应用程序来克服此sql驱动程序问题

I could able to overcome this sql driver issue by adding sql plugin path to the app like below

SQLDriverPath = (r'\\system_xyz\PyQt4\plugins\sqldrivers')
QtGui.QApplication.addLibraryPath(SQLDriverPath)

我开始了解到pyqt4需要qico4.dll才能读取.ico文件. 所以我在应用程序中添加了imageformats路径.但这没用.

I came to understand that pyqt4 needs qico4.dll to read .ico files. so i added the imageformats path to the app. but it did not work.

ImageDriverPath = (r'\\system_xyz\PyQt4\plugins\imageformats')
QtGui.QApplication.addLibraryPath(ImageDriverPath)

任何人都可以建议我一种正确的方法来解决我的问题,即如何通过网络从PyQt应用程序中加载.ico.

Can any one suggest me a correct approach to solve my issue loading .ico in PyQt app from network

我的更新

我做了下面的工作,列出了支持的图像格式.

i did following to list the supported image formats.

import sys

sys.path.append(r'r'\\system_xyz')

from PyQt4 import QtGui

for imageType in QtGui.QImageReader.supportedImageFormats():
    print imageType

输出

bmp
pbm
pgm
png
ppm
xbm
xpm

添加imageformats后,我尝试按上述方式列出,OP相同 甚至在创建QtGui,QApplication()之后尝试过.结果相同,不变.

I tried to list as above after adding imageformats, The OP is the same even tried after creating QtGui,QApplication(). Same result no change.

推荐答案

您可以在qt.conf文件中设置路径,并将此文件放置在应用程序可执行文件的位置.

You can set the paths in qt.conf file and place this file in the location of your executable file of your application.

从网络位置访问PyQt4,例如\ somesystem \ Share \ PyQt4

Accessing PyQt4 from Network Location say \somesystem\Share\PyQt4

您可以在\\ somesystem \ Share \ PyQt4中找到一个qt.conf文件,然后将其复制并将其粘贴到应用程序可执行文件的位置.

you can find a qt.conf file in \\somesystem\Share\PyQt4 copy it and paste the .conf file in the location of your executable file of your application.

在qt.conf中编辑以下几行

edit the below lines in qt.conf

[Paths]
Prefix = //somesystem/Share/PyQt4
Binaries = //somesystem/Share/PyQt4

一切正常,即使sqldrivers也将被加载.无需使用app.addLibraryPath 您还可以在安装程序中包含此文件,以便将其自动安装.

Everything works fine, even sqldrivers will be loaded. No Need of using app.addLibraryPath You can also include this file in your setup so that it will be automatically installed.

这篇关于如何从网络加载PyQt4中的.ico文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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