It is possible to do this using QFormBuilder:
from PyQt4 import QtCore, QtGui, QtDesigner
from myui import Ui_Dialog
def dump_ui(widget, path):
builder = QtDesigner.QFormBuilder()
stream = QtCore.QFile(path)
stream.open(QtCore.QIODevice.WriteOnly)
builder.save(stream, widget)
stream.close()
app = QtGui.QApplication([''])
dialog = QtGui.QDialog()
Ui_Dialog().setupUi(dialog)
dialog.show()
dump_ui(dialog, 'myui.ui')
(NB: showing the window seems to be quite important in order to get the best results).
Don't expect to get a perfect reconstruction of your original ui file, though. You will almost certainly need to do quite a lot of tidying up to get something acceptable - but if your ui is quite complex, it should still be worth it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…