Rewriting inkview in Python
Hi.
It is not that I have a lot of time to do that, but I though that being able to use Inkscape as a library from Python could be an awesome feature to play with. Then one day somebody can come up with alternative SVG viewer.
There are problems with current `inkview` from 0.92.3: - it lacks command line help - it doesn't respond to --version - if doesn't render attached file - there is no scaling option - there is no debug option for troubleshooting my content
The attached file is rendered correctly in Inkscape, although initial view is too small.
On Wed, Nov 21, 2018 at 05:16:30PM +0300, anatoly techtonik wrote:
Hi.
It is not that I have a lot of time to do that, but I though that being able to use Inkscape as a library from Python could be an awesome feature to play with. Then one day somebody can come up with alternative SVG viewer.
There are problems with current `inkview` from 0.92.3:
- it lacks command line help
- it doesn't respond to --version
- if doesn't render attached file
- there is no scaling option
- there is no debug option for troubleshooting my content
The attached file is rendered correctly in Inkscape, although initial view is too small.
-- anatoly t.
At the Hackfest in Germany there were discussions about splitting Inkscape's frontend and backend, and having a defined API in between. This is a big task, but efforts are underway towards that eventual goal. Once that is done, then a python implementation of inkview should theoretically be pretty trivial (and we're hoping it'll spark a number of other similar narrow use case tools and toys).
Until then, I think it might be a lot of work to try and interface python with Inkscape's internals, the way inkview does.
However, changing the command line options to inkview should be fairly straightforward - inkview itself is not a large codebase, and its C++ use is reasonably basic. And there's a lot of folks here who can lend advice. Or, if you really don't want to code it, if you write up in detail what command line options should be, what they should do, and what the help text should say, perhaps another new Inkscaper would be interested in doing the implementation, and could partner with you.
Another option, if you just want to display SVG's and don't care about using Inkscape's actual internals, would be to to make a python wrapper around one of the other SVG renderers, such as librsvg (if they don't have a commandline viewer already). In theory there should not be any rendering discrepancies, but in practice there may well be some flaws, so YMMV.
Bryce
Inkview did get a major overhaul recently (as a warm-up to the recent changes in Inkscape). You might try the trunk version. It at least does
have a --help option and a scale option (still doesn't have --version).
Tav
On Wed, 2018-11-21 at 08:39 -0800, Bryce Harrington wrote:
On Wed, Nov 21, 2018 at 05:16:30PM +0300, anatoly techtonik wrote:
Hi.
It is not that I have a lot of time to do that, but I though that being able to use Inkscape as a library from Python could be an awesome feature to play with. Then one day somebody can come up with alternative SVG viewer.
There are problems with current `inkview` from 0.92.3:
- it lacks command line help
- it doesn't respond to --version
- if doesn't render attached file
- there is no scaling option
- there is no debug option for troubleshooting my content
The attached file is rendered correctly in Inkscape, although initial view is too small.
-- anatoly t.
At the Hackfest in Germany there were discussions about splitting Inkscape's frontend and backend, and having a defined API in between. This is a big task, but efforts are underway towards that eventual goal. Once that is done, then a python implementation of inkview should theoretically be pretty trivial (and we're hoping it'll spark a number of other similar narrow use case tools and toys).
Until then, I think it might be a lot of work to try and interface python with Inkscape's internals, the way inkview does.
However, changing the command line options to inkview should be fairly straightforward - inkview itself is not a large codebase, and its C++ use is reasonably basic. And there's a lot of folks here who can lend advice. Or, if you really don't want to code it, if you write up in detail what command line options should be, what they should do, and what the help text should say, perhaps another new Inkscaper would be interested in doing the implementation, and could partner with you.
Another option, if you just want to display SVG's and don't care about using Inkscape's actual internals, would be to to make a python wrapper around one of the other SVG renderers, such as librsvg (if they don't have a commandline viewer already). In theory there should not be any rendering discrepancies, but in practice there may well be some flaws, so YMMV.
Bryce
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Just added --version option to Inkview.
On Wed, 2018-11-21 at 18:45 +0100, Tavmjong Bah wrote:
Inkview did get a major overhaul recently (as a warm-up to the recent changes in Inkscape). You might try the trunk version. It at least does
have a --help option and a scale option (still doesn't have -- version).
Tav
On Wed, 2018-11-21 at 08:39 -0800, Bryce Harrington wrote:
On Wed, Nov 21, 2018 at 05:16:30PM +0300, anatoly techtonik wrote:
Hi.
It is not that I have a lot of time to do that, but I though that being able to use Inkscape as a library from Python could be an awesome feature to play with. Then one day somebody can come up with alternative SVG viewer.
There are problems with current `inkview` from 0.92.3:
- it lacks command line help
- it doesn't respond to --version
- if doesn't render attached file
- there is no scaling option
- there is no debug option for troubleshooting my content
The attached file is rendered correctly in Inkscape, although initial view is too small.
-- anatoly t.
At the Hackfest in Germany there were discussions about splitting Inkscape's frontend and backend, and having a defined API in between. This is a big task, but efforts are underway towards that eventual goal. Once that is done, then a python implementation of inkview should theoretically be pretty trivial (and we're hoping it'll spark a number of other similar narrow use case tools and toys).
Until then, I think it might be a lot of work to try and interface python with Inkscape's internals, the way inkview does.
However, changing the command line options to inkview should be fairly straightforward - inkview itself is not a large codebase, and its C++ use is reasonably basic. And there's a lot of folks here who can lend advice. Or, if you really don't want to code it, if you write up in detail what command line options should be, what they should do, and what the help text should say, perhaps another new Inkscaper would be interested in doing the implementation, and could partner with you.
Another option, if you just want to display SVG's and don't care about using Inkscape's actual internals, would be to to make a python wrapper around one of the other SVG renderers, such as librsvg (if they don't have a commandline viewer already). In theory there should not be any rendering discrepancies, but in practice there may well be some flaws, so YMMV.
Bryce
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On Thu, Nov 22, 2018 at 1:10 AM Tavmjong Bah <tavmjong@...8...> wrote:
Just added --version option to Inkview.
https://gitlab.com/inkscape/inkscape/commit/09a5e93720955fd6b94874805ad0282c...
\m/
On Wed, Nov 21, 2018 at 8:45 PM Tavmjong Bah <tavmjong@...8...> wrote:
Inkview did get a major overhaul recently (as a warm-up to the recent changes in Inkscape). You might try the trunk version. It at least does
have a --help option and a scale option (still doesn't have --version).
I'd like to try, but I don't see an easy way. Created parallel thread for that.
On Wed, Nov 21, 2018 at 7:40 PM Bryce Harrington <bryce@...961...> wrote:
At the Hackfest in Germany there were discussions about splitting Inkscape's frontend and backend, and having a defined API in between. This is a big task, but efforts are underway towards that eventual goal. Once that is done, then a python implementation of inkview should theoretically be pretty trivial (and we're hoping it'll spark a number of other similar narrow use case tools and toys).
I always forget that it is not trivial to create Python binding for a C++ program. There had been several attempts over the past decade, but I lost track of them. The only project that I know is used in production is https://wiki.qt.io/Qt_for_Python/Shiboken for Qt bindings.
If Python people are able to use at least something from Python and there is a catchy tutorial about how port you favorite missing functions from C++ API to Python, then I am sure more people will follow. I mean I would definitely try this given a lil bit more free time. =)
However, changing the command line options to inkview should be fairly straightforward - inkview itself is not a large codebase, and its C++ use is reasonably basic. And there's a lot of folks here who can lend advice. Or, if you really don't want to code it, if you write up in detail what command line options should be, what they should do, and what the help text should say, perhaps another new Inkscaper would be interested in doing the implementation, and could partner with you.
Thanks. The C++ guiding process will definitely help, The code I do and read nowadays daily involves Bash, Go and Python scripting, and wrapping my head around C++ is just too sloooow to fix some problems with my SVG workflow.
At the very least I'd like `inkview` to automatically scale the output of "systemd-analyze plot" to available screen space, and with --debug option tell me how it selects coordinate systems and maps them together. SVG coordinates in HTML really really needs a good 3D visualization to understand how all this translation and scaling and clipping works with all these abstractions. If inkview could provide more simple output to see how it works, it could become a part of coordinate tutorial itself.
Another option, if you just want to display SVG's and don't care about using Inkscape's actual internals, would be to to make a python wrapper around one of the other SVG renderers, such as librsvg (if they don't have a commandline viewer already). In theory there should not be any rendering discrepancies, but in practice there may well be some flaws, so YMMV.
I tried to find some lib like this, but it is hard without knowing the name. There are a few hits on PYthon Package Index - https://pypi.org/search/?q=librsvg and I would give it a try. Basically the long term idea is a "debugging canvas" - processing like surface for SVG graphics. While filling my issue, I stumbled on the feature request to add reading multiple SVG data chunks from stdin - https://bugs.launchpad.net/inkscape/+bug/1009711 which if implemented would give a simple ability to control the contents of inkview canvas from any program that can run it with an open pipe. -- anatoly t.
understand how all this translation and scaling and clipping works with all these abstractions. If inkview could provide more simple output to see how it works, it could become a part of coordinate tutorial itself.
I think that deserves a separate thread out of `inkview` and Python bindings context, because I forgot to stress that using SVG is a kind of mess, because of those endless coordinates - everything tends to grow of shrink or seems too detailed and overburden the CPU while painting. Having some sane anchor to streamline SVG works with instruments that `inkview` can become that give necessary details about the CPU cycles being used, about details that are missing at the viewing resolution and hints how to optimize glyphs to make processing more simple, and how coordinates are mapped, how to avoid scaling, and simple buttons (or mode with buttons) to optimize for those inefficiencies - that would help people build their SVG composition pipelines for daily small graphics works.
Hi all,
On 23.11.2018 13:01, anatoly techtonik wrote:
I always forget that it is not trivial to create Python binding for a C++ program. There had been several attempts over the past decade, but I lost track of them. The only project that I know is used in production ishttps://wiki.qt.io/Qt_for_Python/Shiboken for Qt bindings.
If Python people are able to use at least something from Python and there is a catchy tutorial about how port you favorite missing functions from C++ API to Python, then I am sure more people will follow. I mean I would definitely try this given a lil bit more free time. =)
I sometimes wrap pieces of C++ code to call them from Python. Of the solutions if tried, the easiest I came across**was *PyBind11*. It was a part of Boost to interface C++ to Python and became a whole library of its own. Needless to say it is pretty well coded.
Checkout the library page : https://github.com/pybind/pybind11 Also, I did setup a few examples to answer questions from colleagues and friends, you can have a look at my github page : https://github.com/cjaques/pybind_examples I wrote a quick article about PyBind, it could be interesting (although everything's on the github page), see this page --> http://christianjaques.ch/pybind-is-great/
I'd be happy to help anyone trying to wrap C++ for Python.
On Fri, Nov 23, 2018 at 3:56 PM Christian Jaques <christian.jaques@...400...> wrote:
Checkout the library page : https://github.com/pybind/pybind11 Also, I did setup a few examples to answer questions from colleagues and friends, you can have a look at my github page : https://github.com/cjaques/pybind_examples I wrote a quick article about PyBind, it could be interesting (although everything's on the github page), see this page --> http://christianjaques.ch/pybind-is-great/
I'd be happy to help anyone trying to wrap C++ for Python.
I remember pybind11. Nice to see it alive and kicking. =)
For the start it will be interesting to see how to replace inkview-main.cpp and call InkviewApplication::create()->run(argc, argv); in Python.
https://gitlab.com/inkscape/inkscape/blob/master/src/inkview-main.cpp
participants (4)
-
anatoly techtonik
-
Bryce Harrington
-
Christian Jaques
-
Tavmjong Bah