Inkscape.org
Creating New Extensions Visual Studio Code: importing inkex for Inkscape 1.0 Beta
  1. #1
    mwinoto mwinoto @mwinoto

    I'm attempting to clean up an existing extention for Inkscape 1.0

    I already have a working version but I'd like to clean up the code further and I'm stuck on the imports.

    My imports look like this

    import math
    import gettext
    from lxml import etree
    import os
    import sys
    sys.path.append('/Users/HomeDir/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions')
    import inkex
    _ = gettext.gettext

     

    The import inkex part is being flagged by pylint and I can't workout why. What's the correct way to import inkex?

    Also what is a good way to reference the path for development?

  2. #2
    Martin Owens Martin Owens @doctormo🌹🧀

    You shouldn't need etree or gettext, etree functionality is available via inkex.elements etc.

    You don't need to add the path in your code. For running locally, you should add the extensions path to your environment PYTHONPATH. Inkscape will automatically add the right paths when it's running extensions.

  3. #3
    mwinoto mwinoto @mwinoto

    Thanks. That worked.

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Visual Studio Code: importing inkex for Inkscape 1.0 Beta