Skip to content

Commit

Permalink
Update plugin to support new printing process:
Browse files Browse the repository at this point in the history
- Set BLOCKING_PRINT to False to automatically use background worker
- Handle "old style" kwargs
- Bump version number
  • Loading branch information
SchrodingersGat committed Jul 14, 2023
1 parent 7a87302 commit 3da0664
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions inventree_brother/brother_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class BrotherLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
SLUG = "brother"
TITLE = "Brother Label Printer"

# Use background printing
BLOCKING_PRINT = False

SETTINGS = {
'MODEL': {
'name': _('Printer Model'),
Expand Down Expand Up @@ -117,8 +120,13 @@ def print_label(self, **kwargs):
# ^ currently this width and height are those of the label template (before conversion to PDF
# and PNG) and are of little use

# Extract image from the provided kwargs
label_image = kwargs['png_file']
# Look for png data in kwargs (if provided)
label_image = kwargs.get('png_file', None)

if not label_image:
# Convert PDF to PNG
pdf_data = kwargs['pdf_data']
label_image = self.render_to_png(label=None, pdf_data=pdf_data)

# Read settings
model = self.get_setting('MODEL')
Expand Down
2 changes: 1 addition & 1 deletion inventree_brother/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version information for the plugin"""

BROTHER_PLUGIN_VERSION = "0.6.1"
BROTHER_PLUGIN_VERSION = "0.7.0"

0 comments on commit 3da0664

Please sign in to comment.