[go: up one dir, main page]

Draft: Add optional progress protocol to script extensions

Experimental!

This feature allows extensions to tell Inkscape about their progress while being busy.

The proposed format is a single line sent and flushed to the stderr pipe where a single hash symbol # is used to denotes a special line¹ while P indicates this signal is a progress indication:

#P:%d,%d,%s

The data that's passed back is two ints and a string representing the value, the maximum value and an optional status message about the progress.

Examples of data that could be fed back to Inkscape include:

  • 3 out of 100 - "3% - Making masks"
  • 35 out of 62 - "35MB written to disk"
  • 3 out of 10 - "Step 3, writing curves"

The numbers would be used to populate visual progress bar widgets, while the message would be used to display to users. This message would be translated by the extension and not by inkscape itself.

The inkex module would be improved to include the needed functions to make this simpler to use from python, similar to the existing ExtensionBase.msg API. But a raw example python program would be:

import sys
...
    sys.stderr.write(f"#P:{amount},{self.max}\n")
    sys.stderr.flush()
...

¹ the use of a hash sign here means future things could be added. This is a simple protocol which honestly, could be changed to use something like protobuf. Although some formats like json, xml etc are not useful here as the data needs to be easy to pick out of a stream.

Edited by Martin Owens

Merge request reports

Loading