PyQt5试水
UI 文件转py文件
工作环境中,conda和python环境并不是我管理的,所以确实不知道常用的pyuic转换程序在哪,最终通过find指令找到了一个能用的,不过是二进制文件。实际使用的时候就是pyuic5 xxx.ui -o xxx.py
Anaconda3-2020.07/bin/pyuic5
pyuic5 --help
Usage: pyuic5 [options] <ui-file>
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-p, --preview show a preview of the UI instead of generating code
-o FILE, --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
-i N, --indent=N set indent width to N spaces, tab if N is 0 [default:
4]
Code generation options:
--import-from=PACKAGE
generate imports of pyrcc5 generated modules in the
style 'from PACKAGE import ...'
--from-imports the equivalent of '--import-from=.'
--resource-suffix=SUFFIX
append SUFFIX to the basename of resource files
[default: _rc]
运行主窗口
if __name__ == '__main__' :
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())