<div dir="ltr">Hi Greg!<div><br></div><div>Thank you very much for your answer!</div><div>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.</div><div>I managed to get what I need from Python directly, using pyBarcode (actually I've used a fork - <a href="https://pypi.python.org/pypi/viivakoodi">viivakoodi</a>), saving the barcode images and then importing them in Scribus by means of another script.</div><div><br></div><div>And my script works inside Scribus up to the part where I use "<i>ImageWriter()</i>"! 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)!</div><div>I just don't understand why, and how can I fix this!</div><div><br></div><div>Thank you again!</div><div><br></div><div>Andrea</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-01 1:59 GMT+02:00 Gregory Pittman <span dir="ltr"><<a href="mailto:gpittman@iglou.com" target="_blank">gpittman@iglou.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03/31/2016 07:25 PM, Andrea Marcon wrote:<br>
> Hello!<br>
> I'm a Python newbie and I'm trying to automatize a task within Scribus.<br>
> I'm producing a large number of labels - for boxes containing products -<br>
> that need to have the barcode of the product.<br>
><br>
> I've written a stand-alone python script that read the numerical code from<br>
> a csv and create a png image, then I wrote another script (run from in<br>
> within Scribus) that creates the layout of the labels and pastes the<br>
> previously created images.<br>
><br>
> I decided to include (i.e. copy-paste) the stand-alone script for barcode<br>
> creation into the Scribus-related one, and it's not working anymore!<br>
> I inserted the stand-alone code as a function, and I call it in the main()<br>
> part.<br>
><br>
> It seems that Python, when working from Scribus scripter, does not<br>
> recognise ImageWriter (from pyBarcode).<br>
> The error it returns is:<br>
><br>
><br>
</span>> *var = barcode.get_barcode('Code128', '1234567891234', writer=<br>
> ImageWriter())*<br>
> *TypeError: 'NoneType' object is not callable*<br>
<span class="">><br>
> I'm kinda sure the problem lays in the "imageWriter()" part, because when I<br>
> took it out the script worked fine, except that produced SVG images instead<br>
> of PNG (as it's supposed to), and that the method's options for modifying<br>
> the resulting SVG image (i.e. dimensions and font size) are not working!<br>
><br>
> Does anybody know what's happening or how to solve it?<br>
><br>
<br>
<br>
</span>My solution was to write my own script for barcodes:<br>
<br>
<a href="https://wiki.scribus.net/canvas/Generating_a_Code39_Barcode" rel="noreferrer" target="_blank">https://wiki.scribus.net/canvas/Generating_a_Code39_Barcode</a><br>
<br>
If you need a Code 39 barcode, you're in luck. Otherwise, it takes some<br>
research to find out the criteria for whatever barcode you need.<br>
I did this because there is no way of generating a barcode from inside<br>
Scribus from scripter. Let's face it, barcodes are just a sequence of<br>
thin and thick lines separated by thin and thick spaces, with something<br>
to mark the beginning and end of the code. So I just did it with short<br>
lines. Notice how I created a dictionary of sorts for alphanumeric<br>
characters.<br>
<br>
I presented this information at one of the Libre Graphics Meetings<br>
several years ago, and someone mentioned that there are Python scripts<br>
you can find for generating barcodes, though they might need some<br>
modifications to adapt to Scribus.<br>
<br>
Greg<br>
<br>
___<br>
Scribus Mailing List: <a href="mailto:scribus@lists.scribus.net">scribus@lists.scribus.net</a><br>
Edit your options or unsubscribe:<br>
<a href="http://lists.scribus.net/mailman/listinfo/scribus" rel="noreferrer" target="_blank">http://lists.scribus.net/mailman/listinfo/scribus</a><br>
See also:<br>
<a href="http://wiki.scribus.net" rel="noreferrer" target="_blank">http://wiki.scribus.net</a><br>
<a href="http://forums.scribus.net" rel="noreferrer" target="_blank">http://forums.scribus.net</a><br>
</blockquote></div><br></div>