Open elpaso opened 2 years ago
CC: @andreasneumann : this might be interesting to you too...
Would there be something to check the scope? Such that:
if scope.IsForm:
form.blah()
else:
somethingElse()
So that this one action could be used both inside a feature form, and outside as a right-click context menu item.
As one who uses actions and drag & drop forms a lot, I'd look forward to this.
Would there be something to check the scope? Such that:
No, that's not planned, but you could check for form
being defined or use a try-except.
Sounds fine to me -- but what approach will you use to expose this? (I.e what's the technical details? :) )
@nyalldawson still a draft: https://github.com/qgis/QGIS/pull/48445
QGIS Enhancement: Drag and drop form actions: expose QgsAttributeForm object to Python
Date 2022/05/02
Author Alessandro Pasotti (@elpaso )
Contact elpaso at itopen dot it
maintainer @elpaso
Version QGIS 3.28
Summary
Since https://github.com/qgis/QGIS/pull/45461 it is possible to add action buttons to the drag and drop forms.
This proposal is to add new "Drag and drop form" scope to Python actions that will automatically expose the current form to the Python code as a
form
local variable.This will make it possible to manipulate all elements of the form including the values of the widgets.
Proposed Solution
Implement a new "Drag and drop form" scope for Python actions.
Expose the current form to the Python code as a
form
variable.Example(s)
Affected Files
qgsattributeform and qgsaction
Performance Implications
None
Backwards Compatibility
None
Votes
(required)