Debugging Extension

Discussion about writing code for Inkscape.
bernie70
Posts: 6
Joined: Mon May 06, 2013 4:43 pm

Debugging Extension

Postby bernie70 » Wed Jan 15, 2014 10:40 pm

Hello,

is there a way to debug an extension I have written?

I want to see the values of variables, etc.

Thanks,
bernie70

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Debugging Extension

Postby ragstian » Wed Jan 15, 2014 11:59 pm

Hi

It's possible by using the inkex.debug() function,
when I do extensions I turn debugging on and off
by one statement in the code (at the beginning of the file), like:

Code: Select all

debug = True # Turns debugging output on - Use debug = False to turn debugging output 'off'

'Later' in the code I have something like this;

Code: Select all

# Just for 'fun' - report Python version
if debug:
    cur_version = sys.version_info
    message = "Python version: " + str(cur_version) + "\n"
    inkex.debug(message)
# More Code
if debug:
    message = ("Using palette files:\n" + inn_file_old + "\n" + inn_file_new + "\n")
    inkex.debug(message)

Hope this helps.

Good Luck
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar


Return to “Programming”