Working on a pybind11 new Scripter for Scribus

Previous topic - Next topic

a.l.e

After a long preparatory phase (and a few fails at upgrading the current solutions), I think that I've finally a way to get to a new Scripter for Scribus that:

- Would have a more sane API
- Is simple to maintain
- Is more pythonic
- Works with Python 3
- Is based on PyQt5 / PySide2 rather than on Tcl/Tk

The first bits, with only two function in the API is here

https://github.com/aoloe/scribus-plugin-scripter-pybind11/

and it allows to get the current file name (if any) with this Python code:

Quote
import scribus
import sys

try:
    doc = scribus.get_current_document()
    print(doc.get_name())
except:
    print("Unexpected error:", sys.exc_info()[0])

If you have some experience with using the Scripter, are a Python programmer or otherwise feel that you have a say, I would be very interested in getting help with the planning of the new API.

As I write in the README linked above, I'd like to create a new API that is close to what the Scripter2 should have been: https://scribus-scripter.readthedocs.io/en/latest/docs/documentapi.html
(the main difference: the return values will be Python objects, not strings with the name of the resource).

Of course, help in the implementation itself would also be welcome, but i hope to be rather fast on not that part (mostly, copying  and refactoring what is already in the current Scripter...).

The plan is to have an API that can do some simple tasks ready for the next LGM

Ciao
a.l.e

P.S.: If you're wondering why: we need a new Scripter because the current solutions cannot be upgraded to Python 3 and Tcl/Tk has issues on Mac OS.

Gibbz

#1
Id love to see python 3 support. One thing ive noticed is that working with python is very slow in some cases. I have some scripts that can take several minutes to process....

Ive made myself a util class that has a lot of helper functions, I guess with a new scripter update we shouldnt need as many of these?

Having some better logging of script to some kind of console would be very handy. Basically a way to open the scripter console window and print to it via python.

a.l.e


Gibbz

#3
Have you made any progress on this?
Im still very keen to be able to bind hotkeys to python scripts.
To have access to pyQT for custom dialogs (using installed python modules from windows).
To be able to insert scripts into the menu items and tool bars (ie Windows > My Custom Dialog).
Access to create and modify tables.

a.l.e

hi gibbz

i'm stuck here:

cannot run two times a script importing PyQt5
https://github.com/pybind/pybind11/issues/1702

there have been no progress since my previous message in here, but if somebody jumps in and wants to help i will be pleased to prioritize the work on the scripter.

if all you want is to start a script by using some keyboard strokes, i think that the easiest way is to apply this patch:

https://bugs.scribus.net/view.php?id=15579

if you get the latest scribus code, you will already have the actions search code installed:

https://bugs.scribus.net/view.php?id=15552

you can then press ctrl+/ and type some letter is in the script's name to start it. if you are a fast typer, it's much more comfortable and fast than a shortcut.
(if you're not a fast typer, i can only encourage you learning touch typing: it's really worth the effort!)

Gibbz

Im afraid I cant help. My c++ knowledge is pretty basic.

The new actions window is great! And the other patch sounds useful too!