diff --git a/printer_helpers.py b/printer_helpers.py index 1457cab..764960d 100644 --- a/printer_helpers.py +++ b/printer_helpers.py @@ -1,3 +1,5 @@ +import os + import barcode from brother_ql import BrotherQLRaster from brother_ql import create_label @@ -12,8 +14,9 @@ def print_bar_code(barcode_value, barcode_text, barcode_type="ean13", rotate=Fal wr = BrotherLabelWriter(typ=label_type, rot=rotate, text=barcode_text, max_height=1000) test = bar_coder(barcode_value, writer=wr) - fn = test.save(barcode_value) - #print_image(fn, printer_type, label_type) + base_path = os.path.dirname(os.path.realpath(__file__)) + fn = test.save(os.path.join(base_path, "bar_codes", barcode_value)) + print_image(fn, printer_type, label_type) def print_image(fn, printer_type="QL-700", label_type="62"): @@ -31,4 +34,4 @@ def print_image(fn, printer_type="QL-700", label_type="62"): printer = BrotherQLBackend(string_descr) - printer.write(qlr.data) \ No newline at end of file + printer.write(qlr.data) diff --git a/text_based.py b/text_based.py index 6735493..0dc7dd0 100755 --- a/text_based.py +++ b/text_based.py @@ -14,6 +14,7 @@ from text_interface.helpermenus import Menu from text_interface.mainmenu import MainMenu from text_interface.miscmenus import ProductSearchMenu, TransferMenu, AdjustCreditMenu, UserListMenu, ShowUserMenu, \ ProductListMenu +from text_interface.printermenu import PrintLabelMenu from text_interface.stats import * random.seed() @@ -47,7 +48,8 @@ if __name__ == '__main__': ProductRevenueMenu(), BalanceMenu(), LoggedStatisticsMenu()]), - FAQMenu() + FAQMenu(), + PrintLabelMenu() ], exit_msg='happy happy joy joy', exit_confirm_msg='Really quit Dibbler?') diff --git a/text_interface/printermenu.py b/text_interface/printermenu.py new file mode 100644 index 0000000..ef63fb3 --- /dev/null +++ b/text_interface/printermenu.py @@ -0,0 +1,20 @@ +from printer_helpers import print_bar_code +from text_interface.helpermenus import Menu +import conf + + +class PrintLabelMenu(Menu): + def __init__(self): + Menu.__init__(self, 'Edit user', uses_db=True) + self.help_text = ''' +Prints out a product bar code on the printer + +Put it up somewhere in the vicinity. +''' + + def _execute(self): + self.print_header() + product = self.input_product('Prodct> ') + + print_bar_code(product.bar_code, product.name, barcode_type="ean13", rotate=False, printer_type="QL-700", + label_type=conf.label_type)