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())

 

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

上一篇:流畅访问Github的方法


下一篇:Selenium操作CEF框架PC应用示例