starting to script the import of external files

Previous topic - Next topic

dragonfly

I'm starting to learn how to add custom scripts .. Scribus 1.4.1

At the foot of this page ..

http://documentation.scribus.net/index.php/The_Scripter

is this ...
QuoteA list of all Scripter commands is available via the Help Browser.

But I can't find any such list of commands.

My interest is a batch script which populates a number of (named) textframes and imageframes from an external directory of text files and images. So I need to map internal frames with external files and for each frame either "Get Text" or "Get Image".

Any tutorials for this (other than reading Scripter in wiki)?



a.l.e

F1

Contents tab

+ For developers
   + Scripter API
      ...


ciao
a.l.e

dragonfly

I've found that reference .. thanks .. and I've read the samples.

But now a basic starter question.
What key sequence or script brings any named (text or image) frame object into focus from a group of predefined frames?

I'm interested in both (a) hot key combinations and (b) scripting (plugin) techniques.

As example of key combos ...
Alt + T + 1 brings textframe1 into focus (selected with red line around frame)
Alt + I + 1 brings imageframe1 into focus (selected ...)
Alt + D + 1 brings renderframe1 into focus (selected ...)

The idea is to batch script "Get Text" and "Get Image" to populate or update frames throughout a multi page document.


a.l.e

no shortcuts for scripts, yet, no...

and for the names, just popup a box asking for the names... or base your script on the current selection...

what i'd like to find one day: a good way to navigation across frames, without using the mouse. not very difficult to program, but i have not found a good set of keybindings...

ciao
a.l.e

dragonfly

#4
The idea was not to use hotkeys combos for running Scribus internal scripts but instead to run workflow automation scripts using tools such as autohotkey (windows) and its similar program autokey (linux).

In theory a macro of key strokes in building a publication might be saved and rerun as a script.

Since I have dual boot windows and ubuntu I tried both utilities.

In Windows I have just installed scribus and autohotkey.

I ran AutoIt3 Window Spy which tracks mouse positions.

But the first problem I encountered is that there is not enough information to target textframes.  See a snapshot of my test configuration with Window Spy monitored my mouse movements.

If you look at any other running programs through Window Spy you will see a ClassNN for objects under "Now Under Mouse Cursor".

But there are no such clues with scribus.   The only information to target is the mouse position or other attributes such as colour of text frame. And there is no assistance in targeting individual fields in the Properties window (to change properties).

My suggestion is that Scribus becomes more "autohotkey and autokey friendly" in later releases so that attributes of textframes and imageframes can be detected more easily using Window Spy .. and thus scripted as macros.

...

For these reasons I'm now focusing on parsing *.sla so that I might traverse frames using the xmldom.


These links have given me some ideas ..

http://wiki.scribus.net/canvas/Draft_for_the_GSoC_Application_Abstract_%28Timo_Stollenwerk%29

http://wiki.scribus.net/canvas/Draft_of_end-to-end_publishing_solution#Use_Case_.233_Publishing_Workflow_for_Magazine_Layout_.28Timo_Stollenwerk.29

http://www.grahl.ch/content/create-reports-scribus-part-1

http://www.grahl.ch/content/create-reports-scribus-drupal-part-2




[attachment deleted by admin]

a.l.e

i see the autokey way of doing as the most challenging one, the hacking on the .sla as a rather bad one and would suggest you again to have a deeper look into scripting.

setting up such a workflow will require a not tiny amount of time, and i believe that you'd better put it in improving the general scripting capabilities rather than to hack an additional layer around scribus that will break at each new scribus repository.

but it's your choice!

have fun
a.l.e

dragonfly

#6
I'm taking your advice to concentrate on learning python scripting (instead of the idea of using autohotkey macros) and I've made some progress after studying the samples in /usr/share/scribus/samples/

Now I have a question on populating textframe and imageframe from queries to a localhost database

How can "Get Text" import into a textframe the text response from a query to a database?

Or "Get Image" import into an imageframe  the image response from a query to a database?

I can see how to connect for the database queries (in my case an XML database and not SQL) .. it is the final step of actually populating the scribus frames with imported content I'm interested in.

i.e. where "File Name" pops up in the finder after "Get Text" or "Get Image" it would be preferable for that to offer the option of "URL" as in accessing content from WebDAV or other server.   Or perhaps add "query URL" to textframe right click context menu.

Thanks.

[Later edit]

Added requirement .. to "Get" new file type *.rtf directly to populate textframe.
If this isn't possible in Scribus I'll look around for a python script to convert *.rtf files to other formats.
Or I've read that AbiWord can be used in command line mode for document type conversion.








a.l.e

for the text it's not that hard to get the text into a text frame... just add it :-)
if you want to use the import filters (no idea which one are currently supported through the scripter... but adding new ones is probably easier than hacking around the .sla files) you can also try to create temporary files and load them

for the images, it's a bit harder: i don't think that there is a way to add an image from a stream of bytes. you will have to create an image on your local file system and import it.

finally, depending on your computer skills and on the goal of your project, you may want to go for the development version of scribus and the new scripter.
this last hint is only valid if you plan to use scribus in a controlled environment (that is on your computer...) and not distribute it.

ciao
a.l.e

dragonfly


I'm beginning to home in on my preferred toolkit which I hope will minimise the need for scripting or getting into Scribus development.

My thoughts in Ubuntu 12.04 are now

Install Scrivener. It has a very reasonable price tag after a generous beta usage.  I'm still using the free beta on Linux and Windows.

Install Zotero for citations

Install Scribus

Now ..

Use Scrivener as the front end story editor, using "Scrivenings" which are fragments of the total story which can be moved around very easily.

Compile these "Scrivenings" into final *.doc format.   You can use Scrivener to publish and print directly into different formats at Compile stage but the next step I'm opting for in my own workflow is to use the compiled *.doc format as the source to now populate a Scribus blank document pre-configured with textframes.

Create document layout in Scribus.

There is quite a bit of overlap of functionality in using both Scrivener and Scribus but I'm prepared to work with that to get the extra flexibility .. particularly by using Scrivener as the front end story editor and Scribus as the layout and publish editor

So my core toolkit of choice is [Scrivener + Zotero + Scribus].


References:

http://www.livinpixels.com/edu/2012/09/how-to-hook-up-scrivener-zotero/

and see the videos here ..

http://forum.asymmetrical.co/threads/a-beginners-guide-to-using-scrivener.173/

in particular see this on Scrivener compiling .. the stage before importing into Scribus

http://www.literatureandlatte.com/videos/CompilingUsingFormatPresetsSmall.mov

...

Collaborative editing of documents is yet another subject and I'm looking at syncing content in WebDAV.

i.e. allowing multiple contributors to create a document for publication.

....