小编Leo*_*eon的帖子

在Python中使用uic将.ui文件转换为.py文件时出错

我正在尝试用 python 编写一个程序,它将同一文件夹(在 Qt Designer 中创建)中的 .ui 文件转换为 .py 文件。这是这个极其基本的程序的代码:

# -*- coding: utf-8 -*-

from PyQt4 import uic

with open('exampleinterface.py', 'w') as fout:
    uic.compileUi('exampleinterface.ui', fout)
Run Code Online (Sandbox Code Playgroud)

它给出以下错误(缩短长路径名):

回溯(最近一次调用最后一次):

文件“”,第 1 行,位于

文件“...\Python32_3.5\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”,第 699 行,在运行文件 execfile(文件名,命名空间)中

文件“...\Python32_3.5\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”,第 88 行,在 execfile 中 exec(compile(open(filename, 'rb').read(), filename , 'exec'), 命名空间) 文件“.../Documents/Python/UiToPy/minimalconvert.py”,第 11 行,位于 uic.compileUi('exampleinterface.ui', fout)

文件“...\Python32_3.5\lib\site-packages\PyQt4\uic__init__.py”,第 173 行,在compileUi winfo =compiler.UICompiler().compileUi(uifile, pyfile, from_imports, resource_suffix)

文件“...\Python32_3.5\lib\site-packages\PyQt4\uic\Compiler\compiler.py”,第 140 行,在compileUi w = self.parse(input_stream,resource_suffix)中

文件“...\Python32_3.5\lib\site-packages\PyQt4\uic\uiparser.py”,第 974 行,在解析文档 = parse(filename) 中

文件“...\Python32_3.5\lib\xml\etree\ElementTree.py”,第 1182 行,在 parse tree.parse(source, parser) 中

文件“...\Python32_3.5\lib\xml\etree\ElementTree.py”,第 594 …

python pyqt qt-designer

3
推荐指数
1
解决办法
8535
查看次数

标签 统计

pyqt ×1

python ×1

qt-designer ×1