如何从QtDesigner文件生成python代码?我找到了pyside-uic,但是我找不到语法的例子。我用spyder运行win7和pythonxy。
发布于 2011-05-04 19:33:14
pyside-uic与pyuic4大致相同,因此手册页指定:
Usage:
pyside-uic [options] <ui-file>
Options:
--version
show program's version number and exit
-h,--help
show this help message and exit
-oFILE,--output=FILE
write generated code to FILE instead of stdout
-x,--execute
generate extra code to test and display the class
-d,--debug
show debug output
-iN,--ident=N
set indent width to N spaces, tab if N is 0 (default: 4)
我通常这样使用它:
pyside-uic -o output.py input.ui
发布于 2012-01-04 03:52:36
刚刚试用了Pyside的QUILoader,运行良好:
from PySide import QtGui
from PySide import QtCore
from PySide import QtUiTools
class MyWidget(QtGui.QMainWindow):
def __init__(self, *args):
apply(QtGui.QMainWindow.__init__, (self,) + args)
loader = QtUiTools.QUiLoader()
file = QtCore.QFile("pyside_ui_qtdesigner_form_test.ui")
file.open(QtCore.QFile.ReadOnly)
self.myWidget = loader.load(file, self)
file.close()
self.setCentralWidget(self.myWidget)
if __name__ == '__main__':
import sys
import os
print("Running in " + os.getcwd() + " .\n")
app = QtGui.QApplication(sys.argv)
win = MyWidget()
win.show()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"),
app, QtCore.SLOT("quit()"))
app.exec_()
我使用Eclipse和QTDesigner创建了.ui文件(右键单击模块,"New -> Other..",选择"Qt Designer -> Qt Designer Form")。不需要显式uic调用。
发布于 2011-12-03 05:45:14
pyside-uic.exe MyWindow.ui -o MyWindow.py
就是我一直在做的,它工作得很好(据我所知)
https://stackoverflow.com/questions/4442286
复制相似问题