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!
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!
The question has already been answered, but if you are looking for a shortcut during development, including this at the top of your python script will save you some time but mostly let you forget about actually having to make the conversion.
I've ran into the same problem recently. After finding the correct path to the pyuic4 file using the file finder I've ran:
As you can see my ui file was placed in this folder...
QT Creator was installed separately and the pyuic4 file was placed there with the OSGEO4W installer
You can use
pyuic4
command on shell:pyuic4 input.ui -o output.py
Update for anyone using PyQt5 with python 3.x:
.ui
file."C:\python\Lib\site-packages\PyQt5\pyuic5.bat" -x Trial.ui -o trial_gui.py
for cases where PyQt5 is not a path variable. The path in quotes " " represents where thepyuic5.bat
file is.This should work!
For pyqt5 you can use
or
You don't have to install PyQt4 with all its side features, you just need the PyQt4 package itself. Inside the package you could use the module pyuic.py ("C:\Python27\Lib\site-packages\PyQt4\uic") to convert your Ui file.
You will get all options listed:
So your command will look like this:
You could also use full file paths to your file to convert it.
Why do you want to convert it anyway? I prefer creating widgets in the designer and implement them with via the *.ui file. That makes it much more comfortable to edit it later. You could also write your own widget plugins and load them into the Qt Designer with full access. Having your ui hard coded doesn't makes it very flexible.
I reuse a lot of my ui's not only in Maya, also for Max, Nuke, etc.. If you have to change something software specific, you should try to inherit the class (with the parented ui file) from a more global point of view and patch or override the methods you have to adjust. That saves a lot of work time. Let me know if you have more questions about it.