Merge branch 'development' into python-barcode

This commit is contained in:
Patrick Kanzler 2020-05-08 23:37:43 +02:00 committed by GitHub
commit 8dae31d783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 0 deletions

39
.github/workflows/pythonpackage.yml vendored Normal file
View File

@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
tox

View File

@ -1,8 +1,10 @@
Ahmed Tahri Ahmed Tahri
akeonly akeonly
Alexander Bougakov
Alex Debiasio Alex Debiasio
Asuki Kono Asuki Kono
belono belono
Brian
Christoph Heuel Christoph Heuel
Cody (Quantified Code Bot) Cody (Quantified Code Bot)
csoft2k csoft2k
@ -19,6 +21,7 @@ Kristi
ldos ldos
Lucy Linder Lucy Linder
Manuel F Martinez Manuel F Martinez
Maximilian Wagenbach
Michael Billington Michael Billington
Michael Elsdörfer Michael Elsdörfer
mrwunderbar666 mrwunderbar666

View File

@ -77,6 +77,25 @@ Another example based on the Network printer class:
kitchen.barcode('1324354657687', 'EAN13', 64, 2, '', '') kitchen.barcode('1324354657687', 'EAN13', 64, 2, '', '')
kitchen.cut() kitchen.cut()
Another example based on the Serial printer class:
.. code:: python
from escpos.printer import Serial
""" 9600 Baud, 8N1, Flow Control Enabled """
p = Serial(devfile='/dev/tty.usbserial',
baudrate=9600,
bytesize=8,
parity='N',
stopbits=1,
timeout=1.00,
dsrdtr=True)
p.text("Hello World\n")
p.qr("You can readme from your smartphone")
p.cut()
The full project-documentation is available on `Read the Docs <https://python-escpos.readthedocs.io>`_. The full project-documentation is available on `Read the Docs <https://python-escpos.readthedocs.io>`_.

View File

@ -102,6 +102,9 @@ class Escpos(object):
* `graphics`: prints with the `GS ( L`-command * `graphics`: prints with the `GS ( L`-command
* `bitImageColumn`: prints with the `ESC *`-command * `bitImageColumn`: prints with the `ESC *`-command
When trying to center an image make sure you have initialized the printer with a valid profile, that
contains a media width pixel field. Otherwise the centering will have no effect.
:param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp` :param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp`
:param high_density_vertical: print in high density in vertical direction *default:* True :param high_density_vertical: print in high density in vertical direction *default:* True
:param high_density_horizontal: print in high density in horizontal direction *default:* True :param high_density_horizontal: print in high density in horizontal direction *default:* True
@ -113,6 +116,10 @@ class Escpos(object):
im = EscposImage(img_source) im = EscposImage(img_source)
try: try:
if self.profile.profile_data['media']['width']['pixels'] == "Unknown":
print("The media.width.pixel field of the printer profile is not set. " +
"The center flag will have no effect.")
max_width = int(self.profile.profile_data['media']['width']['pixels']) max_width = int(self.profile.profile_data['media']['width']['pixels'])
if im.width > max_width: if im.width > max_width: