Skip to content

WIP: Integrating Python into Inkscape (as opposed to calling it externally)

Thomas Wiesner requested to merge wiesi/inkscape:python-internal into master

This branch integrates the Python interpreter into Inkscape and allows to use Inkscape functionality directly via Python code.

Current functionality:

  • Inkscape-integrated Python console with basic command history and message coloring (different colors for log messages, input, output and errors)
  • A pane for selecting Python files and running them
  • A rudimentary set of bindings:
    • Arbitrary Inkscape verbs can be run
    • Files can be opened
    • Files can be saved. Selecting the output file type on basis of a MIME type, i.e., export to other file types than .svg is supported, but the user interaction dialog for the export settings pops up.
    • PNG export
    • Listing and activating desktops (open files)
  • Running Python scripts from the command line is possible, although only in non-GUI mode.

Information for testing:

  • Currently only tested on Debian 9.
  • The cmake script searches only for Python 3.5. If found, a line containing "WITH_EMBPYTHON: ON" should be output when running cmake.
  • The Python console is located in Edit => Python console in the main menu.
  • Some Python scripting tests and examples can be found in share/python/tests of the source tree.
  • Simple test: Entering print(_ipy.getVersion()) in the console should print Inkscape's version string.
  • Run help(_ipy) in the console to print the documentation of the implemented functionality.

Known bugs: See issues on GitLab.

Screenshots:

console scripts

Edited by Thomas Wiesner

Merge request reports