Skip to content

Commit 93b4bce

Browse files
committed
option to override ean text with an human readable text
for example (gives a more readable text): options = dict(human='1 234567 890123')
1 parent 467aaa2 commit 93b4bce

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

barcode/writer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def __init__(self, initialize=None, paint_module=None, paint_text=None,
8787
self.background = 'white'
8888
self.foreground = 'black'
8989
self.text = ''
90+
self.human = '' # human readable text
9091
self.text_distance = 5
9192
self.center_text = True
9293

@@ -251,7 +252,12 @@ def _create_text(self, xpos, ypos):
251252
'middle;'.format(self.foreground,
252253
self.font_size))
253254
_set_attributes(element, **attributes)
254-
text_element = self._document.createTextNode(self.text)
255+
# check option to override self.text with self.human (barcode as human readable data, can be used to print own formats)
256+
if self.human != '':
257+
barcodetext = self.human
258+
else:
259+
barcodetext = self.text
260+
text_element = self._document.createTextNode(barcodetext)
255261
element.appendChild(text_element)
256262
self._group.appendChild(element)
257263

0 commit comments

Comments
 (0)