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

Gregory Pittman gpittman at iglou.com
Thu Mar 31 23:59:05 UTC 2016


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



More information about the scribus mailing list