Ability to have own menu with scripts?

Previous topic - Next topic

digirew

Anyone know if its possible to create a new menu in Scribus and have our own custom scripts placed in the drop down menu?

a.l.e

one and a half years ago i've made a patch to achieve exactly this:

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

it sleeps in the bug tracker and waits for being reviewed and possibly accepted...

ciao
a.l.e

digirew

nice! - I vote a thumbs up on this one to make it into the next release.

a.l.e

we're not on instagram here... thumbs up are completely useless : - )
(despite my small ego boost)

what you can do:

- if you can compile scribus, try out the patch and see how well it works for you (and comment in the ticket)
- if you can read c++ code, review the code and give feedback
- otherwise, read all details in the ticket and try to understand if it is a good approach and comment in the ticket.

sorry for the bad news...

a.l.e

digirew

Unfortunately I dont have the expertise to compile at this time.

I will review the ticket and make comments if needed and hopfully it makes it into the next release.

dragonfly

A thought about a workaround.
Not exactly in an integrated menu .. but .. I would include in the core scripts a simple script which open a custom dialogue to allow choosing external python modules to be imported into Scripter.  The external folder containing custom scripts has to be on sys.path.

One reference to using external modules found here.
https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html


a.l.e

i think that it would be preferable to get scribus or its scripts to recognize venvs / virtual environments.

i had a short look at it last week but i could not find a good solution.
but i stumbled on a longer ticket / bug report that made me think that venv cannot be used yet in a scripting context.
but it should be possible with virtualenv.

does anybody have any further insight?

ciao
a.l.e

p.s: of course, if i recall correctly it's trivial to start scribus from inside of a venv... but the idea would be that one can define from inside of scribus which venv to use... in the ideal case, it's a per script "configuration".

dragonfly

Quotei think that it would be preferable to get scribus or its scripts to recognize venvs / virtual environments.

.. but why? Can you explain the reasoning?

Meanwhile, as another "outlier" idea, I am focussing on using PHP for server side scripting. Some rough experiments allow custom Scribus documents to be parsed either in localhost or remote PHP server.
The principle of using variables (as in ScribusGenerator) is followed by embedding PHP variables in Scribus templates but large chunks of content can then be merged into Scribus template and "compiled" *.sla downloaded to be run in desktop Scribus.

a.l.e

why the usage of venv / virtualenv?

then you can set up an environment and get scribus to point to it and cleanly access all libraries it needs for running the scripts.

you can add a requirements.txt to your script and anybody who gets them can run your script without having to perform special tricks.

that should work in a similar way as in most python IDEs, where you can (create or) pick a venv.

(iirc) right now -- at least on linux -- you can achieve the same effect by starting scribus from terminal with an activated venv.
that's really cool, but i can't expect the users of my scripts to do the same.



and as i've already had the chance to write in the past, i don't like the idea of messing around with the xml in the .sla files. there are a few reasons for that.
in short: directly editing a .sla is ok to solve a specific sudden problem. but i would not build a long term business on top of it.
(mainly: you get a fragile solution and since your solution is not general or even portable, it does not improve the scribus ecosystem)
(on top of it: several have tried in the past and the scribus generator is the only effort that somehow succeeded; still, i think i've demonstrated that it's possible to implement it in scribus itself and -- at the same time -- make scribus a better place; it makes me a bit sad to see how much work that has been put into the generator... but the scribus project is also at fault there.)

a.l.e

i've digged further in the recent past of my research and here are a few links:

Using Virtualenv without bin/python
https://virtualenv.pypa.io/en/legacy/userguide.html#using-virtualenv-without-bin-python

Make it easier to use a venv with an embedded Python interpreter
https://bugs.python.org/issue35706

Make pyvenv style virtual environments easier to configure when embedding Python
https://bugs.python.org/issue22213

not an easy read and my conclusion is that there are currently no way to get it to work on all three main target platforms.

Derek

Attaching my own scripts to a sub-menu is definitely something I would use. I'm sure anyone who develops their own scripts gets tired of them dropping off the 'Recent Scripts' list. Far better for the frequently used ones to have a fixed home IMHO.

I hope this gets the interest it needs to finally make its way into the system. For now, I'm playing around with adding my own scripts to /usr/share/scribus/scripts/.