Files
kassenspiel/main.py
2020-11-14 17:22:20 +01:00

79 lines
2.5 KiB
Python

# This is a sample Python script.
# Press ⇧F10 to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
from escpos.printer import Usb
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
articles = {
'40267609': {
'price': 3.99,
'name': 'kleber'
},
'5449000138170': {
'price': 1.50,
'name': 'fanta zero'
},
'4005401170006': {
'price': 1.50,
'name': 'stift'
},
'4012700987020': {'price': 2.00, 'name': 'tintenkiller'}, '4006381333634': {'price': 2.50, 'name': 'textmarker'},
'4006381333214': {'price': 1.00, 'name': 'filzstift'}, '4005401743354': {'price': 5.00, 'name': 'zirkel'},
'4006144241022': {'price': 3.00, 'name': 'schulheft'},
'9783551050113': {'price': 0.50, 'name': 'pixibuch'}, '9781474969314': {'price': 8.00, 'name': 'puzzle pad'},
'4009900533652': {'price': 1.00, 'name': 'kaugummis'}, '746775261344': {'price': 11.00, 'name': 'scrabble junior'},
'4000540000108': {'price': 9.00, 'name': 'haferflocken'}
}
def main():
printer = Usb(0x04B8, 0x0202, profile="TM-T88V")
while True:
endprice = 0
barcode = 'x'
while barcode != '' and barcode != 'XXXX':
barcode = input()
print(barcode)
if barcode in articles:
print(articles[barcode]['name'], articles[barcode]['price'])
endprice += articles[barcode]['price']
printer.textln(f"{barcode}")
printer.textln(f"{articles[barcode]['name']} {articles[barcode]['price']}")
printer.textln()
print('-------------------')
print(endprice)
print()
print()
printer.textln('-------------------')
printer.textln(endprice)
printer.textln(" Danke für den Einkauf ")
printer.cut()
def createproduct():
barcode = ' '
products = []
while barcode != '':
barcode = input()
print('name:', end='')
name = input()
print('price:', end='')
price = input()
products.append(f"'{barcode}': {{ 'price': {price}, 'name': '{name}' }}")
print(','.join(products))
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('Lily')
# createproduct()
main()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/