[scribus] Python scripting issue with ImageWriter - "NoneType object is not callable" error

Andrea Marcon amarcon.work at gmail.com
Fri Apr 1 00:10:19 UTC 2016


Hi Greg!

Thank you very much for your answer!
I found your script some time ago while searching for a solution and I
really appreciated it, but I couldn't find a way to write my own for
"Code128" barcodes.
I managed to get what I need from Python directly, using pyBarcode
(actually I've used a fork - viivakoodi
<https://pypi.python.org/pypi/viivakoodi>), saving the barcode images and
then importing them in Scribus by means of another script.

And my script works inside Scribus up to the part where I use "
*ImageWriter()*"! When I simply delete this word (it's actually enough to
delete the parenthesys), the script produces the SVG images (in a folder
from where I'll load them into Scribus later in the script)!
I just don't understand why, and how can I fix this!

Thank you again!

Andrea

2016-04-01 1:59 GMT+02:00 Gregory Pittman <gpittman at iglou.com>:

> On 03/31/2016 07:25 PM, Andrea Marcon wrote:
> > Hello!
> > I'm a Python newbie and I'm trying to automatize a task within Scribus.
> > I'm producing a large number of labels - for boxes containing products -
> > that need to have the barcode of the product.
> >
> > I've written a stand-alone python script that read the numerical code
> from
> > a csv and create a png image, then I wrote another script (run from in
> > within Scribus) that creates the layout of the labels and pastes the
> > previously created images.
> >
> > I decided to include (i.e. copy-paste) the stand-alone script for barcode
> > creation into the Scribus-related one, and it's not working anymore!
> > I inserted the stand-alone code as a function, and I call it in the
> main()
> > part.
> >
> > It seems that Python, when working from Scribus scripter, does not
> > recognise ImageWriter (from pyBarcode).
> > The error it returns is:
> >
> >
> > *var = barcode.get_barcode('Code128', '1234567891234', writer=
> > ImageWriter())*
> > *TypeError: 'NoneType' object is not callable*
> >
> > I'm kinda sure the problem lays in the "imageWriter()" part, because
> when I
> > took it out the script worked fine, except that produced SVG images
> instead
> > of PNG (as it's supposed to), and that the method's options for modifying
> > the resulting SVG image (i.e. dimensions and font size) are not working!
> >
> > Does anybody know what's happening or how to solve it?
> >
>
>
> My solution was to write my own script for barcodes:
>
> https://wiki.scribus.net/canvas/Generating_a_Code39_Barcode
>
> If you need a Code 39 barcode, you're in luck. Otherwise, it takes some
> research to find out the criteria for whatever barcode you need.
> I did this because there is no way of generating a barcode from inside
> Scribus from scripter. Let's face it, barcodes are just a sequence of
> thin and thick lines separated by thin and thick spaces, with something
> to mark the beginning and end of the code. So I just did it with short
> lines. Notice how I created a dictionary of sorts for alphanumeric
> characters.
>
> I presented this information at one of the Libre Graphics Meetings
> several years ago, and someone mentioned that there are Python scripts
> you can find for generating barcodes, though they might need some
> modifications to adapt to Scribus.
>
> Greg
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20160401/fcd1eda8/attachment.html>


More information about the scribus mailing list