Interactive Python Shell extension?

Discussion about writing code for Inkscape.
gijsvanoort
Posts: 1
Joined: Wed Nov 23, 2011 9:19 am

Interactive Python Shell extension?

Postby gijsvanoort » Wed Nov 23, 2011 9:34 am

Hello,

I would like to create an Inkscape extension in Python. In order to learn how to deal with everything (especially the structure of self.document.getroot()), I would like to be able to get into an interactive Python shell when executing the plugin (as opposed to executing a Python file directly). I that possible?

I tried to modify the .inx-file line
<command reldir="extensions" interpreter="python">file.py</command>
to
<command reldir="extensions" interpreter="python"></command>
hoping that Python would be invoked without a file as argument (and thus opening the interactive shell). Didn't work.

Anyone an idea how to do this?

Thanks,

Gijs van Oort

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: Interactive Python Shell extension?

Postby LiquidAsh » Thu Nov 24, 2011 9:17 am

One problem that you may run into is that inkscape reads you're python script's output as a complete svg document, rather than printing it to the screen for debugging...

I suspect that for learning purposes, you may be better off capturing a copy of inkscape's tmp document and command line parameters, and then loading those into your interactive shell for experimentation. I suspect that you could have a script do this saving, and forking of a shell environment that would (at that point) be detached from inkscape.

Another useful tool in learning your way around the svg document is the svg specification: http://www.w3.org/TR/SVG/, and your specific document's code in inkscape via the Edit > XML Editor menu choice.

sgmanohar
Posts: 3
Joined: Thu Aug 21, 2014 2:41 pm

Re: Interactive Python Shell extension?

Postby sgmanohar » Fri Aug 22, 2014 4:14 am

I have written a very simple extension to Inkscape that may do what you want!
It allows 5 lines of python code to be typed in, via the GUI, and iterated over objects.
You can iterate over the selection, or over an XPath.
Best of all, you don't have to leave inkscape!
http://www.smanohar.com/inkscape.php

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Interactive Python Shell extension?

Postby hulf2012 » Fri Aug 22, 2014 7:40 am

Hello
It's very interesting, but your download link is wrong, at least for me. It sends to you to your webpage.

Also, your examples, ...well, are not clear to me. I hope you could help.
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.


Return to “Programming”