FreeCAD加载ui文件显示于组合浏览器

把下面代码更改ui文件后粘贴到Python控制台

视图---面板---Python控制台

import FreeCAD
import FreeCADGui
from PySide import QtCore, QtGui
 
class CalculateSum:
    def __init__(self):
        # Importing the form from Qt UI file.
        self.form = FreeCADGui.PySideUic.loadUi("F:/Program Files/FreeCAD 0.18/Mod/Desk_ui_FC/MyCreateBlock.ui")
 
        # Setting on-click behavior of Calculate button
        QtCore.QObject.connect(self.form.btn_cteate, QtCore.SIGNAL("clicked()"), self.accept)
 
    def accept(self):
        """Will be called when Calculate button is clicked"""
        # Take inputs from both fields.
        v1 = int(self.form.lineEdit_length.text())
        v2 = int(self.form.lineEdit_length.text())
        print("Sum of "+str(v1)+" and "+str(v2)+": "+str(v1+v2))
   
# Show up in FreeCAD.

if FreeCAD.GuiUp:
    import FreeCADGui
    FreeCADGui.Control.showDialog(CalculateSum())

转载仅为学习,不会商用。
欢迎转载原创,附文链接。
原文地址:https://www.cnblogs.com/xdd1997/p/15113405.html