Got the variables editor to populate with controls for each of the variables in the script.
This commit is contained in:
parent
896bcca7c9
commit
81d1f4e850
|
@ -346,6 +346,10 @@ class ToggleParametersEditor:
|
|||
if not isPresent:
|
||||
cqVariablesEditor = QtGui.QDockWidget("CadQuery Variables Editor")
|
||||
cqVariablesEditor.setObjectName("cqVarsEditor")
|
||||
# cqVariablesEditor.setAutoFillBackground(True)
|
||||
# p = cqVariablesEditor.palette()
|
||||
# p.setColor(cqVariablesEditor.backgroundRole(), '#FF0000')
|
||||
# cqVariablesEditor.setPalette(p)
|
||||
mw.addDockWidget(QtCore.Qt.LeftDockWidgetArea, cqVariablesEditor)
|
||||
|
||||
|
||||
|
@ -378,7 +382,7 @@ class CadQueryValidateScript:
|
|||
if "build_object(" not in scriptText or "# build_object(" in scriptText or "#build_boject(" in scriptText:
|
||||
FreeCAD.Console.PrintError("Script did not call build_object, no output available. Script must be CQGI compliant to get build output, variable editing and validation.\r\n")
|
||||
return
|
||||
|
||||
|
||||
# A repreentation of the CQ script with all the metadata attached
|
||||
cqModel = cqgi.parse(scriptText)
|
||||
|
||||
|
|
26
Shared.py
26
Shared.py
|
@ -94,19 +94,39 @@ def populateParameterEditor(parameters):
|
|||
"""Puts the proper controls in the script variable editor pane based on the parameters found"""
|
||||
|
||||
FreeCAD.Console.PrintMessage("Script Variables:\r\n")
|
||||
for key, value in parameters.iteritems():
|
||||
FreeCAD.Console.PrintMessage("variable name: " + key + ", variable value: " + str(value.default_value) + "\r\n")
|
||||
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
|
||||
# Tracks whether or not we have already added the variables editor
|
||||
isPresent = False
|
||||
|
||||
# TODO: Clear and then populate the controls in the widget based on the variables
|
||||
# https://stackoverflow.com/questions/3940409/how-to-clear-all-the-widgets-in-parent-widgets
|
||||
|
||||
# If the widget is open, we need to close it
|
||||
dockWidgets = mw.findChildren(QtGui.QDockWidget)
|
||||
for widget in dockWidgets:
|
||||
if widget.objectName() == "cqVarsEditor":
|
||||
# TODO: Clear and then populate the controls in the widget based on the variables
|
||||
gridLayout = QtGui.QGridLayout()
|
||||
|
||||
line = 1
|
||||
for pKey, pVal in parameters.iteritems():
|
||||
FreeCAD.Console.PrintMessage("variable name: " + pKey + ", variable value: " + str(pVal.default_value) + "\r\n")
|
||||
label = QtGui.QLabel(pKey)
|
||||
value = QtGui.QLineEdit()
|
||||
value.setText(str(pVal.default_value))
|
||||
btn = QtGui.QPushButton("OK")
|
||||
gridLayout.addWidget(label, line, 0)
|
||||
gridLayout.addWidget(value, line, 1)
|
||||
gridLayout.addWidget(btn, line, 2)
|
||||
|
||||
line += 1
|
||||
|
||||
# Create a widget we can put the layout in
|
||||
newWidget = QtGui.QWidget()
|
||||
newWidget.setLayout(gridLayout)
|
||||
|
||||
widget.setWidget(newWidget)
|
||||
|
||||
# Toggle the visibility of the widget
|
||||
# if widget.visibleRegion().isEmpty():
|
||||
|
|
Loading…
Reference in New Issue
Block a user