Convert pyQt UI to python

2019-01-16 11:28发布

Is there a way to convert a ui formed with qtDesigner to a python version to use without having an extra file?

I'm using Maya for this UI, and converting this UI file to a readable python version to implement would be really great!

10条回答
欢心
2楼-- · 2019-01-16 11:56

Quickest way to convert .ui to .py is from terminal:

pyuic4 -x input.ui -o output.py

Make sure you have pyqt4-dev-tools installed.

查看更多
时光不老,我们不散
3楼-- · 2019-01-16 11:58

For Ubuntu it works for following commands; If you want individual files to contain main method to run the files individually, may be for testing purpose,

pyuic5 filename.ui -o filename.py -x

No main method in file, cannot run individually... try

pyuic5 filename.ui -o filename.py

Consider, I'm using PyQT5.

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-16 11:59

If you are using windows, the PyQt4 folder is not in the path by default, you have to go to it before trying to run it:

c:\Python27\Lib\site-packages\PyQt4\something> pyuic4.exe full/path/to/input.ui -o full/path/to/output.py

or call it using its full path

full/path/to/my/files> c:\Python27\Lib\site-packages\PyQt4\something\pyuic4.exe input.ui -o output.py
查看更多
虎瘦雄心在
5楼-- · 2019-01-16 12:04

I'm not sure if PyQt does have a script like this, but after you install PySide there is a script in pythons script directory "uic.py". You can use this script to convert a .ui file to a .py file:

python uic.py input.ui -o output.py -x
查看更多
登录 后发表回答