[PySide] PySide uic

ameya dambir ameyadambir at gmail.com
Wed Oct 17 08:53:20 CEST 2012


Hi,

I manged to edit that cod but still I am getting some errors.
def loadUiType(uiFile):
        """
        Pyside lacks the "loadUiType" command, so we have to convert the ui
file to py code in-memory first
        and then execute it in a special frame to retrieve the form_class.
        """
        parsed = xml.parse(uiFile)
        widget_class = parsed.find('widget').get('class')
        form_class = parsed.find('class').text

        with open(uiFile, 'r') as f:
            o = StringIO()
            frame = {}

            pysideuic.compileUi(f, o, indent=0)
            pyc = compile(o.getvalue(), '<string>', 'exec')
            exec(pyc, frame)

            #Fetch the base_class and form class based on their type in the
xml from designer
            form_class = frame['Ui_%s'%form_class]
            base_class = eval('QtGui.%s'%widget_class)
        return form_class, base_class

temp=os.path.join(os.path.split(__file__)[0],'create_connection_dlg.ui')
FormClass, BaseClass = loadUiType(temp)

This is my code and errors are
 File "create_connection_dlg.py", line 39, in <module>
    FormClass, BaseClass = loadUiType(temp)
  File "create_connection_dlg.py", line 29, in loadUiType
    pysideuic.compileUi(f, o, indent=0)
  File
"/disk/ve/dev/ameya.dambir/install/p4workspace/products/dotrox/py32/linux-amd64-gcc_4_1-release/lib/python3.2/site-packages/pysideuic/__init__.py",
line 142, in compileUi
    winfo = compiler.UICompiler().compileUi(uifile, pyfile, from_imports)
  File
"/disk/ve/dev/ameya.dambir/install/p4workspace/products/dotrox/py32/linux-amd64-gcc_4_1-release/lib/python3.2/site-packages/pysideuic/Compiler/compiler.py",
line 91, in compileUi
    w = self.parse(input_stream)
  File
"/disk/ve/dev/ameya.dambir/install/p4workspace/products/dotrox/py32/linux-amd64-gcc_4_1-release/lib/python3.2/site-packages/pysideuic/uiparser.py",
line 859, in parse
    document = parse(filename)
  File "<string>", line 62, in parse
  File "<string>", line 38, in parse
cElementTree.ParseError: no element found: line 1, column 0

Can anybody help??

Ameya

On Tue, Oct 16, 2012 at 5:10 PM, Jens Lindgren
<jens.lindgren.vfx at gmail.com>wrote:

> He has a example code on that page, did you check it out?
>
> /Jens
>
> On Tue, Oct 16, 2012 at 12:54 PM, ameya dambir <ameyadambir at gmail.com>wrote:
>
>> Hi,
>>
>>
>> I have an old codefromPyQt which I am migrating to PySide.
>> I am trying to import uic module, but I am getting an error. I am not
>> sure whether this is installed correctly or not and about using it.
>>
>> >>from PySide import QtGui,uic
>> ImportError: cannot import name uic
>>
>>
>> This what I am looking at.
>> What is the meaning of the directory named pysideuic?
>>
>> I read on this page "http://nathanhorne.com/?p=451" that pysideuic has
>> lacking a function loadUiType, is it true?
>> If yes then how should I port my code?
>> Can any body help?
>>
>> Thanks in advance!!
>>
>> Ameya
>>
>>
>>
>> _______________________________________________
>> PySide mailing list
>> PySide at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/pyside
>>
>>
>
>
> --
> Jens Lindgren
> --------------------------
> Lead Technical Director
> Magoo 3D Studios <http://www.magoo3dstudios.com/>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20121017/3cc42f9e/attachment.html>


More information about the PySide mailing list