Add option to cancel creation of feature in warning message
This commit is contained in:
parent
a8c89eb45b
commit
f0efdc08a1
|
@ -36,6 +36,9 @@ def executeFeature(obj):
|
||||||
try:
|
try:
|
||||||
obj.Proxy.execute(obj)
|
obj.Proxy.execute(obj)
|
||||||
obj.purgeTouched()
|
obj.purgeTouched()
|
||||||
|
except CancelError:
|
||||||
|
FreeCAD.ActiveDocument.abortTransaction()
|
||||||
|
raise
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
mb = QtGui.QMessageBox()
|
mb = QtGui.QMessageBox()
|
||||||
mb.setIcon(mb.Icon.Warning)
|
mb.setIcon(mb.Icon.Warning)
|
||||||
|
@ -58,9 +61,19 @@ def warning(obj,message):
|
||||||
mb.setIcon(mb.Icon.Warning)
|
mb.setIcon(mb.Icon.Warning)
|
||||||
mb.setText(u"Warning: \n" + message)
|
mb.setText(u"Warning: \n" + message)
|
||||||
mb.setWindowTitle("Warning")
|
mb.setWindowTitle("Warning")
|
||||||
|
btnAbort = mb.addButton(QtGui.QMessageBox.StandardButton.Abort)
|
||||||
|
btnOK = mb.addButton("Continue",QtGui.QMessageBox.ButtonRole.ActionRole)
|
||||||
|
mb.setDefaultButton(btnOK)
|
||||||
mb.exec_()
|
mb.exec_()
|
||||||
|
if mb.clickedButton() is btnAbort:
|
||||||
|
raise CancelError()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
FreeCAD.Console.PrintWarning(obj.Name + ": " + message)
|
FreeCAD.Console.PrintWarning(obj.Name + ": " + message)
|
||||||
else:
|
else:
|
||||||
FreeCAD.Console.PrintWarning(message)
|
FreeCAD.Console.PrintWarning(message)
|
||||||
|
|
||||||
|
class CancelError(Exception):
|
||||||
|
def __init__(self):
|
||||||
|
self.message = "Canceled by user"
|
Loading…
Reference in New Issue
Block a user