-
-
Save su-v/8e391048e9269a93dbaf to your computer and use it in GitHub Desktop.
Inkscape debug extension: returns the number of command line arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- file: myTest.inx --> | |
<!-- deps: myTest.py --> | |
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> | |
<_name>MyTest</_name> | |
<id>local/org.inkscape.debug.effect.myTest</id> | |
<dependency type="executable" location="extensions">myTest.py</dependency> | |
<dependency type="executable" location="extensions">inkex.py</dependency> | |
<param name="instructions" type="description" xml:space="preserve">myTest</param> | |
<effect needs-document="true" needs-live-preview="true"> | |
<object-type>all</object-type> | |
<effects-menu hidden="false"> | |
<submenu _name="Debug" /> | |
</effects-menu> | |
</effect> | |
<script> | |
<command reldir="extensions" interpreter="python">myTest.py</command> | |
</script> | |
<options silent="true"></options> | |
</inkscape-extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
myTest - template Inkscape test extension | |
Copyright (C) 2012 ~suv, suv-sf@users.sf.net | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation; either version 2 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
""" | |
# system library | |
from datetime import date | |
import sys | |
# local library | |
import inkex | |
try: | |
inkex.localize() | |
except: | |
inkex.errormsg("inkex.localize() failed.\n") | |
import gettext | |
_ = gettext.gettext | |
class testDebug(inkex.Effect): | |
def __init__(self): | |
inkex.Effect.__init__(self) | |
def effect(self): | |
today = date.today() | |
inkex.errormsg(_("Today is %s" % today)) | |
inkex.errormsg(_("Number of selected objects: %s" % len(self.selected))) | |
inkex.errormsg(_("Length of list of command line arguments passed to Python script: %s" % len(sys.argv))) | |
# for ele in sys.argv: | |
# inkex.debug(ele) | |
if __name__ == '__main__': | |
e = testDebug() | |
e.affect() | |
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment