[PySide] Enums in Python wrapper for a Qt-base library

Alberto Mardegan mardy at users.sourceforge.net
Fri Nov 23 18:42:37 CET 2012


Hi all!
  I've one Qt-base library, let's call it libabc.so, and I want to make
a PyABC python wrapper for it. All the libabc API is contained in a
namespace, called "ABC". Now, when I generate the bindings, I'm using a
typesystem file like this:

===========================
<?xml version="1.0"?>
<typesystem package="PyABC">
  <load-typesystem name="typesystem_core.xml" generate="no" />
  <namespace-type name="ABC" generate="no">
    <enum-type name="ImageType"/>
    <object-type name="Image" />
  </namespace-type>
</typesystem>
===========================

I've set the 'generate="no"' attribute on the namespace, otherwise all
classes are only accessible as PyABC.ABC.<ItemName>. This works well,
except for the enums. For some reason, the enum values are accessible in
three different ways:

1) PyABC.ABC.ImageType.Value1
2) PyABC.ImageType.Value1
3) PyABC.Value1

where the first one seems to be the canonical one; that is, if I run a
python interpreter and import the PyABC module, and then type
"PyABC.Value1" on the prompt, it types back "PyABC.ABC.ImageType.Value1".

Is there a way to have the enum values being exported in the second form
only (that is, PyABC.ImageType.Value1)?
Or at least, is there a way to make the 3rd form unavailable, as it's
just polluting the module namespace?

TIA,
  Alberto

-- 
http://blog.mardy.it <- geek in un lingua international!



More information about the PySide mailing list