Skip to content

Add Python expressions support #203

Description

@ThomasG77

When people use expressions, they sometimes do not find specific functions. You have to make some of them using Python expressions.

Although expressions can be already published, is there any way to also push Python expressions? I missed the functionality or not available?

Triggered by recurring questions on the QGIS users mailing list like https://lists.osgeo.org/pipermail/qgis-user/2021-May/048919.html

Should be possible using the following Python function

@qgsfunction(args='auto', group='Layout')
def get_page_format(layoutname, pagenumber, feature, parent, context):
    layout = QgsProject.instance().layoutManager().layoutByName(layoutname)
    page = layout.pageCollection().page(pagenumber - 1)
    return QgsApplication.pageSizeRegistry().find(page.pageSize())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions