feat: add several options for customizing label placement
* --row-wise, for going left to right instead of top to bottom * --num-labels, for specifying how many labels to print * --pages, for specifying how many pages to print * --start-position, for continuing on sheets where some labels were already used Co-authored-by: Jan Christian Grünhage <jan.christian@gruenhage.xyz>
This commit is contained in:
parent
a6e8fadf72
commit
d5d9b7adad
13 changed files with 1990 additions and 10 deletions
|
|
@ -89,7 +89,9 @@ BUSINESS_CARDS = 5371
|
|||
|
||||
|
||||
class AveryLabel:
|
||||
def __init__(self, label, debug, **kwargs):
|
||||
def __init__(self, label, debug,
|
||||
topDown=True, start_pos=None,
|
||||
**kwargs):
|
||||
data = labelInfo[label]
|
||||
self.across = data.labels_horizontal
|
||||
self.down = data.labels_vertical
|
||||
|
|
@ -99,10 +101,27 @@ class AveryLabel:
|
|||
self.size[1] + data.gutter_size[1],
|
||||
)
|
||||
self.margins = data.margin
|
||||
self.topDown = True
|
||||
self.topDown = topDown
|
||||
self.debug = debug
|
||||
self.pagesize = data.pagesize
|
||||
self.position = 0
|
||||
|
||||
#Calculate start offset
|
||||
if isinstance(start_pos, tuple):
|
||||
rows, columns = start_pos
|
||||
# Minimum Value 1 for row/column
|
||||
rows = max(rows, 1)
|
||||
columns = max(columns, 1)
|
||||
if self.topDown:
|
||||
offset = (columns - 1) * self.down + rows - 1
|
||||
else:
|
||||
offset = (rows - 1) * self.across + columns - 1
|
||||
elif start_pos:
|
||||
offset = start_pos - 1
|
||||
else:
|
||||
offset = 0
|
||||
# Limit start position to number of labels - 1
|
||||
self.position = min(offset, self.across * self.down - 1)
|
||||
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
def open(self, filename):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue