PySide SVG image formats not found?

2024/10/7 10:14:56

I am using PyDev plugin for Eclipse with Qt integration. I have PySide installed and I am having trouble with SVG image formats. I know when I run my application the formats located in C:\Python27\Lib\site-packages\PySide\plugins\imageformats are found. All but the SVG format. I can remove the qico4.dll and it no longer finds them and put it back in and it finds them again.

I am using this line in my code: plugs = QtGui.QImageReader.supportedImageFormats()

It finds all of the formats except the SVG format from the qsvg4.dll? Why would this be? I have searched and searched and searched and can’t seem to find out why. Should the format show up in the supported image formats? Is there something else I need to do to use SVG images? I can use .ico files fine which require the qico4.dll and is located in the same place which is why I am not understanding what the problem is? Any help is appreciated!

Answer

In order to use SVG images, you need to import QtSvg and QtXml and also ensure that the plugin directory is imported properly.

The following code does that successfully for me:

import os
import PySide
from PySide import QtSvg, QtXml
# You need to have created your QApplication already...
qApp = QApplication.instance()
for plugins_dir in [os.path.join(p, "plugins") for p in PySide.__path__]:qApp.addLibraryPath(plugins_dir)
https://en.xdnf.cn/q/70258.html

Related Q&A

convert ascii character to signed 8-bit integer python

This feels like it should be very simple, but I havent been able to find an answer..In a python script I am reading in data from a USB device (x and y movements of a USB mouse). it arrives in single AS…

What is the equivalent way of doing this type of pythonic vectorized assignment in MATLAB?

Im trying to translate this line of code from Python to MATLAB:new_img[M[0, :] - corners[0][0], M[1, :] - corners[1][0], :] = img[T[0, :], T[1, :], :]So, naturally, I wrote something like this:new_img(…

How do I connect mitmproxy to another proxy outside of my control?

The process would be that the browser send a request to MITMproxy and then generate a request that gets sent to target proxy server which isnt controlled by us. The proxy server would send a response t…

How does conda-env list / conda info --envs find environments?

Ive been experimenting with anaconda/miniconda because my users use structural biology programs installed with miniconda and none of the authors A) take into account that there might be other miniconda…

Updating a large number of entities in a datastore on Google App Engine

I would like to perform a small operation on all entities of a specific kind and rewrite them to the datastore. I currently have 20,000 entities of this kind but would like a solution that would scale …

Is there a neater alternative to `except: pass`?

I had a function that returned a random member of several groups in order of preference. It went something like this:def get_random_foo_or_bar():"Id rather have a foo than a bar."if there_are…

Get a permutation as a function of a unique given index in O(n)

I would like to have a function get_permutation that, given a list l and an index i, returns a permutation of l such that the permutations are unique for all i bigger than 0 and lower than n! (where n …

How to generate Bitcoin keys/addresses from a seed in Python?

I am trying to create a set of public/private keys from a mnemonic based on BIP0039. I am working in Python.Here is the code I have so far:from mnemonic import Mnemonic mnemon = Mnemonic(english) words…

NumPy - Set values in structured array based on other values in structured array

I have a structured NumPy array:a = numpy.zeros((10, 10), dtype=[("x", int),("y", str)])I want to set values in a["y"] to either "hello" if the corresponding val…

numpy.disutils.system_info.NotFoundError: no lapack/blas resources found

Problem: Linking numpy to correct Linear Algebra libraries. Process is so complicated that I might be looking for the solution 6th time and I have no idea whats going wrong. I am on Ubuntu 12.04.5. I …