Added a try-catch to avoid errors due disabled workbenches

This commit is contained in:
Paul Ebbers 2025-01-11 14:16:58 +01:00
parent 0c8bb6b866
commit f8b36b25c1
2 changed files with 11 additions and 28 deletions

View File

@ -9,12 +9,7 @@ translate = App.Qt.translate
def toolbarAction(nfo):
act = nfo["action"]
print(
"show toolbar "
+ act["toolbar"]
+ " from workbenches "
+ repr(act["workbenches"])
)
print("show toolbar " + act["toolbar"] + " from workbenches " + repr(act["workbenches"]))
def subToolAction(nfo):
@ -50,10 +45,7 @@ def subToolAction(nfo):
return True
elif action is not None:
print(
"Run action of tool "
+ toolPath
+ " available in workbenches "
+ repr(act["workbenches"])
"Run action of tool " + toolPath + " available in workbenches " + repr(act["workbenches"])
)
action.trigger()
return True
@ -64,25 +56,21 @@ def subToolAction(nfo):
else:
for workbench in act["workbenches"]:
print("Activating workbench " + workbench + " to access tool " + toolPath)
try:
FreeCADGui.activateWorkbench(workbench)
except Exception:
print("Workbench not present")
return
if runTool():
return
print(
"Tool "
+ toolPath
+ " not found, was it offered by an extension that is no longer present?"
)
print("Tool " + toolPath + " not found, was it offered by an extension that is no longer present?")
def toolbarToolTip(nfo, setParent):
workbenches = FreeCADGui.listWorkbenches()
in_workbenches = [
"<li>"
+ (
Serialize_SearchBar.iconToHTML(QtGui.QIcon(workbenches[wb].Icon))
if wb in workbenches
else "? "
)
+ (Serialize_SearchBar.iconToHTML(QtGui.QIcon(workbenches[wb].Icon)) if wb in workbenches else "? ")
+ wb
+ "</li>"
for wb in nfo["action"]["workbenches"]
@ -97,12 +85,7 @@ def toolbarToolTip(nfo, setParent):
def subToolToolTip(nfo, setParent):
return (
Serialize_SearchBar.iconToHTML(nfo["icon"], 32)
+ "<p>"
+ nfo["toolTip"]
+ "</p>"
)
return Serialize_SearchBar.iconToHTML(nfo["icon"], 32) + "<p>" + nfo["toolTip"] + "</p>"
def getAllToolbars():

View File

@ -5,7 +5,7 @@
<description>Adds a search bar widget for tools, document objects, and preferences</description>
<version>1.3.1.1</version>
<version>1.3.1.2</version>
<date>2022-06-01</date>