本文将介绍怎样使用QT designer创建界面后,将其转化为Python代码然后
用于FreeCAD中
对话框的创建(QT designer)
1、打开QT designer,首先创建一个对话框,有几个选项:
Dialog with Buttons Bottom
Dialog with Buttons Right
Dialog without Buttons
Main Window
Widget
选择一个点击创建
2、选择edit ---> 编辑窗口部件 F3
此时可以从左边的widget Box中拖曳部件到你的对话框中
3、选择edit ---> 编辑信号和槽
可以编辑信号和槽
将.ui文件转换成.py文件(pyutic4)
安装Python后还有安装相应的pyutic4工具,pyutic4工具要和系统已经已安装
的Python版本相对应,然后在Python->Lib->site-packages->PyQt4
->pyuic4.bat,pyuic4.bat是一个Windows批处理文件,将其路径添加到windows
的环境变量Path中,重启以后可以使用。
使用方法:cmd命令行 --> pyuic4 XXXX.ui > XXXX.py
转化的python文件中可以看见:
class Ui_Dialog:
def setupUi(self,Dialog):
....
def retranslateUi(self,Dialog):
...
setupUi、retranslateUi函数 :用于初始化各个不同的控件
此外还可以自己添加一些函数或者变量
用于FreeCAD中
作为一个模块导入FreeCAD的Python文件中即可
用于FreeCAD中
对话框的创建(QT designer)
1、打开QT designer,首先创建一个对话框,有几个选项:
Dialog with Buttons Bottom
Dialog with Buttons Right
Dialog without Buttons
Main Window
Widget
选择一个点击创建
2、选择edit ---> 编辑窗口部件 F3
此时可以从左边的widget Box中拖曳部件到你的对话框中
3、选择edit ---> 编辑信号和槽
可以编辑信号和槽
将.ui文件转换成.py文件(pyutic4)
安装Python后还有安装相应的pyutic4工具,pyutic4工具要和系统已经已安装
的Python版本相对应,然后在Python->Lib->site-packages->PyQt4
->pyuic4.bat,pyuic4.bat是一个Windows批处理文件,将其路径添加到windows
的环境变量Path中,重启以后可以使用。
使用方法:cmd命令行 --> pyuic4 XXXX.ui > XXXX.py
转化的python文件中可以看见:
class Ui_Dialog:
def setupUi(self,Dialog):
....
def retranslateUi(self,Dialog):
...
setupUi、retranslateUi函数 :用于初始化各个不同的控件
此外还可以自己添加一些函数或者变量
用于FreeCAD中
作为一个模块导入FreeCAD的Python文件中即可