Converting .py to .ui file

19,198

Solution 1

Qt/PyQt doesn't come with a tool for that, and AFAIK nobody's written one.

And it's hard to imagine why you'd need it. Just keep the .ui file around, and never edit the generated .py file (or even use the .ui file dynamically at runtime with uic), and you'll never need to reverse-convert.

Meanwhile, if you've got some random PyQt4 code that generates a GUI that wasn't even created by pyuic4, there's no guarantee that any .ui could possibly generate the code. (In fact, most of the PyQt samples you'll find online don't do things the same way pyuic4 would, and most likely any other code generator will similarly not do things the same way pyuic4 does.)

Solution 2

I can give you an example of why such a thing: when you inherited a project and the original developer didn't place the ui files in the repository (only left there the generated by pyuic4). True, that is a very particular example and that's also my reason why I'm trying to find something (is not a matter of one single ui file).

In a more generic way I can imagine that this would had happen to the previous developer in case of a disk fail.

Yes, I'm completely agreed that such a tool is not a normal thing to be provided like pyuic4...

Share:
19,198
Ali
Author by

Ali

Updated on June 11, 2022

Comments

  • Ali
    Ali almost 2 years

    We already know that we can convert from ui to py easily with pyuic4.

    Is possible to convert .py (that only contains pyqt ui related stuff) code back to .ui.