--default-label-size and --default-orientation

This commit is contained in:
Philipp Klaus 2017-02-06 14:10:13 +01:00
parent 64a1ba5eb7
commit f9507358ed
3 changed files with 24 additions and 5 deletions

View File

@ -27,9 +27,13 @@ To start the server, run `./brother_ql_web.py`. Here's its command line interfac
usage: brother_ql_web.py [-h] [--port PORT] [--loglevel LOGLEVEL]
[--font-folder FONT_FOLDER]
[--default-label-size DEFAULT_LABEL_SIZE]
[--default-orientation {standard,rotated}]
[--model {QL-500,QL-550,QL-560,QL-570,QL-580N,QL-650TD,QL-700,QL-710W,QL-720NW,QL-1050,QL-1060N}]
printer
This is a web service to print labels on Brother QL label printers.
positional arguments:
printer String descriptor for the printer to use (like
tcp://192.168.0.23:9100 or file:///dev/usb/lp0)
@ -40,5 +44,11 @@ To start the server, run `./brother_ql_web.py`. Here's its command line interfac
--loglevel LOGLEVEL
--font-folder FONT_FOLDER
folder for additional .ttf/.otf fonts
--default-label-size DEFAULT_LABEL_SIZE
Label size inserted in your printer. Defaults to 62.
--default-orientation {standard,rotated}
Label orientation, defaults to "standard". To turn
your text by 90°, state "rotated".
--model {QL-500,QL-550,QL-560,QL-570,QL-580N,QL-650TD,QL-700,QL-710W,QL-720NW,QL-1050,QL-1060N}
The model of your printer (default: QL-500)

View File

@ -23,6 +23,8 @@ DEBUG = False
MODEL = None
BACKEND_CLASS = None
BACKEND_STRING_DESCR = None
DEFAULT_ORIENTATION = None
DEFAULT_LABEL_SIZE = None
FONTS = None
DEFAULT_FONT = None
DEFAULT_FONTS = [
@ -48,7 +50,7 @@ def labeldesigner():
label_sizes = LABEL_SIZES
title = 'Label Designer'
page_headline = 'Brother QL Label Designer'
return {'title': title, 'page_headline': page_headline, 'message': '', 'fonts': fonts, 'label_sizes': label_sizes}
return {'title': title, 'page_headline': page_headline, 'message': '', 'fonts': fonts, 'label_sizes': label_sizes, 'default_label_size': DEFAULT_LABEL_SIZE, 'default_orientation': DEFAULT_ORIENTATION}
def get_label_context(request):
""" might raise LookupError() """
@ -204,12 +206,14 @@ def print_text():
return return_dict
def main():
global DEBUG, FONTS, DEFAULT_FONT, MODEL, BACKEND_CLASS, BACKEND_STRING_DESCR
global DEBUG, FONTS, DEFAULT_FONT, MODEL, BACKEND_CLASS, BACKEND_STRING_DESCR, DEFAULT_ORIENTATION, DEFAULT_LABEL_SIZE
import argparse
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--port', default=8013)
parser.add_argument('--loglevel', type=lambda x: getattr(logging, x.upper()), default='WARNING')
parser.add_argument('--font-folder', help='folder for additional .ttf/.otf fonts')
parser.add_argument('--default-label-size', default="62", help='Label size inserted in your printer. Defaults to 62.')
parser.add_argument('--default-orientation', default="standard", choices=('standard', 'rotated'), help='Label orientation, defaults to "standard". To turn your text by 90°, state "rotated".')
parser.add_argument('--model', default='QL-500', choices=models, help='The model of your printer (default: QL-500)')
parser.add_argument('printer', help='String descriptor for the printer to use (like tcp://192.168.0.23:9100 or file:///dev/usb/lp0)')
args = parser.parse_args()
@ -226,6 +230,11 @@ def main():
MODEL = args.model
if args.default_label_size not in label_sizes:
parser.error("Invalid --default-label-size. Please choose on of the following:\n:" + " ".join(label_sizes))
DEFAULT_LABEL_SIZE = args.default_label_size
DEFAULT_ORIENTATION = args.default_orientation
FONTS = get_fonts()
if args.font_folder:
FONTS.update(get_fonts(args.font_folder))

View File

@ -24,14 +24,14 @@
<div class="chooser panel-body">
<label for="labelSize" style="display: none">Label Size:</label>
<select class="form-control" id="labelSize" onChange="preview()">
{% for label_size in label_sizes %}<option value="{{label_size[0]}}">{{label_size[1]}}</option>{% endfor %}
{% for label_size in label_sizes %}<option value="{{label_size[0]}}" {% if default_label_size == label_size[0] %}selected{% endif %}>{{label_size[1]}}</option>{% endfor %}
</select>
<label for="orientation" style="margin-top: 10px; margin-bottom: 0">Label Orientation:</label>
<div class="radio" style="margin-top: 5px;">
<label><input type="radio" onchange="preview()" name="orientation" value="standard" checked>Standard</label>
<label><input type="radio" onchange="preview()" name="orientation" value="standard" {% if default_orientation == 'standard' %}checked{% endif %}>Standard</label>
</div>
<div class="radio">
<label><input type="radio" onchange="preview()" name="orientation" value="rotated">Rotated</label>
<label><input type="radio" onchange="preview()" name="orientation" value="rotated" {% if default_orientation == 'rotated' %}checked{% endif %}>Rotated</label>
</div>
</div> <!-- class="chooser panel-body" -->
</div>