Guest User

Untitled

a guest
Jun 12th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 25.55 KB | None | 0 0
  1. from Tkinter import *
  2. import tkMessageBox
  3. from PIL import Image, ImageTk
  4. import sys
  5. import mysql.connector
  6. import pickle
  7. import datetime
  8.  
  9.  
  10. # Global Variable Declarations
  11. scannerinput = "" # Characters input by the barcode scanner
  12. keypadValue = "" # Value currently entered into the keypad0
  13. keypadMode = "Currency" # Currency or Quantity
  14. menu = "Main" # Currently active menu
  15. subtotal = 0.00 # Total of items before tax
  16. taxrate = 1.07 # Tax rate constant
  17. total = 0.00 # Total including tax
  18. registerTotal = 0.00 # Current register count
  19.  
  20. # Connect to local database
  21. cnx = mysql.connector.connect(user='root', password='Horsetoaster99', host='localhost', database='schemainventory')
  22. cursor = cnx.cursor()
  23.  
  24. # Handle keyboard/barcode scanner input
  25. def keyInput(event):
  26.     global scannerinput
  27.     global menu
  28.     if menu == "Sale" or "Ebay Sale":
  29.         print "pressed", repr(event.char)
  30.         if event.char != '\r':
  31.             scannerinput += event.char
  32.         else:
  33.             print "Item scanned."
  34.             itemScanned()
  35.  
  36. # An item was scanned
  37. def itemScanned():
  38.     print "ITEM SCANNED"
  39.     global cursor
  40.     global menu
  41.     global scannerinput
  42.     global items
  43.     query = ("SELECT name, qty, saleprice FROM inventory WHERE id = '" + scannerinput + "'")
  44.     cursor.execute(query)
  45.     for (name, qty, saleprice) in cursor:
  46.         #print name
  47.         #print qty
  48.         #print saleprice
  49.         newItem = item()
  50.         newItem.id = scannerinput
  51.         newItem.name = name
  52.         newItem.qty = 1
  53.         newItem.price = saleprice
  54.         items.insert(0, newItem)
  55.     if menu == "Sale":
  56.         updateItemsList()
  57.     if menu == "Ebay Sale":
  58.         updateEbaySaleList()
  59.  
  60.     scannerinput = ''
  61.  
  62. # Convert keypad string to currency float
  63. def keypadToCurrency(keypadString):
  64.     if keypadString != "":
  65.         return float(keypadString[0:len(keypadString) - 2]) + (float(keypadString[2:0 - 1]) / 100)
  66.     else: return 0
  67.  
  68. # Open Sale Menu
  69. def saleMenu():
  70.     global menu
  71.     global items
  72.     items = list()
  73.     updateItemsList()
  74.     menu = "Sale"
  75.     menuMain.pack_forget()
  76.     menuSale.pack()
  77.  
  78. # Open Sale Menu Quantity Adjustment
  79. def saleMenuQuantity():
  80.     global menu
  81.     menu = "Sale Quantity"
  82.     global keypadValue
  83.  
  84.     keypadValue = ""
  85.  
  86.     global keypadMode
  87.  
  88.     keypadMode = "Quantity"
  89.  
  90.     keypad.place(width=436, height=480)
  91.     confirmCancel.place(x=600, y=390)
  92.     keypadDisplay.config(text="1")
  93.     menuSale.pack_forget()
  94.  
  95. # Open Sale Menu Pay Cash
  96. def saleMenuPayCash():
  97.     global menu
  98.     menu = "Sale Pay Cash"
  99.     global keypadValue
  100.  
  101.     keypadValue = ""
  102.  
  103.     global keypadMode
  104.  
  105.     keypadMode = "Currency"
  106.  
  107.     keypad.place(width=436, height=480)
  108.     confirmCancel.place(x=600, y=390)
  109.     keypadDisplay.config(text="$0.00")
  110.     menuSale.pack_forget()
  111.  
  112. # Open card payment confirmation menu
  113. def saleMenuPayCard():
  114.     global menu
  115.     global total
  116.     menu = "Sale Pay Card"
  117.  
  118.     menuConfirmSale.pack()
  119.     labelChangeConfirm.config(text="Total Charge: " + '${:,.2f}'.format(total))
  120.     confirmCancel.place(x=600, y=390)
  121.     menuSale.pack_forget()
  122.  
  123. # Open Transactions menu
  124. def transactionsMenu():
  125.     global menu
  126.     menu = "Transactions"
  127.     updateTransactionsListbox()
  128.     menuMain.pack_forget()
  129.     menuTransactions.pack()
  130.     confirmCancel.place(x=600, y=390)
  131.  
  132. # Open transaction details menu
  133. def transactionDetailsMenu():
  134.     global menu
  135.     menu = "Transaction Details"
  136.     menuTransactions.pack_forget()
  137.     menuTransactionDetail.pack()
  138.     confirmCancel.place(x=600, y=390)
  139.  
  140. # Exit transaction details menu
  141. def transactionDetailsMenuBack():
  142.     global menu
  143.     menu = "Transactions"
  144.     menuTransactionDetail.pack_forget()
  145.     menuTransactions.pack()
  146.  
  147. # Exit transactions menu
  148. def transactionsMenuBack():
  149.     global menu
  150.     menu = "Main"
  151.     menuTransactions.pack_forget()
  152.     menuMain.pack()
  153.  
  154. # Open Adjustment Menu
  155. def adjustmentMenu():
  156.     global menu
  157.     global keypadValue
  158.     global keypadMode
  159.     menuMain.pack_forget()
  160.     menuAdjust.pack()
  161.     keypad.place(width=436, height=480)
  162.     keypadMode = "Currency"
  163.     keypadValue = ""
  164.     keypadUpdate()
  165.     menu = "Adjust"
  166.  
  167. def adjustmentMenuBack():
  168.     global menu
  169.     menu = "Main"
  170.     menuAdjust.pack_forget()
  171.     keypad.place_forget()
  172.     menuMain.pack()
  173.  
  174. def adjustmentMenuAdd():
  175.     global menu
  176.     global keypadValue
  177.     global registerTotal
  178.     global cursor
  179.     global cnx
  180.  
  181.     if keypadValue == "":
  182.         return
  183.  
  184.     amount = keypadToCurrency(keypadValue)
  185.     registerTotal += amount
  186.  
  187.     d = datetime.datetime.now()
  188.  
  189.     query = ("INSERT INTO transactions "
  190.              "(totalsale, items, transactiontype, paymentmethod, salestax, datetime, itemcount)"
  191.              "VALUES (%s, %s, %s, %s, %s, %s, %s)")
  192.     data = (amount, "", "ADJT", "CASH", "0", d.strftime('%Y-%m-%d %H:%M:%S'), 0)
  193.     cursor.execute(query, data)
  194.     cnx.commit()
  195.  
  196.     keypadValue = ""
  197.     menu = "Main"
  198.     keypad.place_forget()
  199.     menuAdjust.pack_forget()
  200.     menuMain.pack()
  201.  
  202. def adjustmentMenuSub():
  203.     global menu
  204.     global keypadValue
  205.     global registerTotal
  206.     global cursor
  207.     global cnx
  208.  
  209.     if keypadValue == "":
  210.         return
  211.  
  212.     amount = keypadToCurrency(keypadValue)
  213.     registerTotal -= amount
  214.  
  215.     d = datetime.datetime.now()
  216.  
  217.     query = ("INSERT INTO transactions "
  218.              "(totalsale, items, transactiontype, paymentmethod, salestax, datetime, itemcount)"
  219.              "VALUES (%s, %s, %s, %s, %s, %s, %s)")
  220.     data = (-amount, "", "ADJT", "CASH", "0", d.strftime('%Y-%m-%d %H:%M:%S'), 0)
  221.     cursor.execute(query, data)
  222.     cnx.commit()
  223.     keypadValue = ""
  224.  
  225.     menu = "Main"
  226.     keypad.place_forget()
  227.     menuAdjust.pack_forget()
  228.     menuMain.pack()
  229.  
  230. # Open Generic Item Menu
  231. def genericItemMenu():
  232.     global menu
  233.     global keypadMode
  234.     global keypadValue
  235.     keypadMode = "Currency"
  236.     keypadValue = ""
  237.     keypadUpdate()
  238.     menuSale.pack_forget()
  239.     menuGenericItem.pack()
  240.     keypad.place(width=436, height=480)
  241.     keypadMode = "Currency"
  242.     menu = "Generic Item"
  243.  
  244. def genericItemMenuBack():
  245.     global menu
  246.     keypad.place_forget()
  247.     menuGenericItem.pack_forget()
  248.     menuSale.pack()
  249.     menu = "Sale"
  250.  
  251. # Open Ebay sale menu
  252. def ebaySaleMenu():
  253.     global menu
  254.     global items
  255.     items = list()
  256.     updateEbaySaleList()
  257.     menu = "Ebay Sale"
  258.     menuMain.pack_forget()
  259.     menuEbaySale.pack()
  260.     confirmCancel.place(x=600, y=390)
  261.  
  262. # Add generic item to list
  263. def addGenericItem(name):
  264.     global menu
  265.     if keypadValue == "":
  266.         return
  267.     price = keypadToCurrency(keypadValue)
  268.     newItem = item()
  269.     newItem.name = name
  270.     newItem.price = price
  271.     items.insert(0, newItem)
  272.     updateItemsList()
  273.     menuGenericItem.pack_forget()
  274.     keypad.place_forget()
  275.     menuSale.pack()
  276.     menu = "Sale"
  277.  
  278. # Update the database after a transaction is made
  279. def logTransaction(transactiontype, paymentmethod):
  280.     global cursor
  281.     global cnx
  282.     global items
  283.     global subtotal
  284.     global total
  285.     d = datetime.datetime.now()
  286.  
  287.     for i in items:
  288.         print i.id
  289.         print str(i.qty)
  290.         query = ("UPDATE inventory SET qty = qty - " + str(i.qty) + " WHERE id='" + i.id + "'")
  291.         cursor.execute(query)
  292.  
  293.         query = ("UPDATE inventory SET totalsold = totalsold + " + str(i.qty) + " WHERE id='" + i.id + "'")
  294.         cursor.execute(query)
  295.  
  296.         print d.strftime('%Y-%m-%d %H:%M:%S')
  297.         query = ("UPDATE inventory SET lastsold = '" + d.strftime('%Y-%m-%d %H:%M:%S') + "' WHERE id='" + i.id + "'")
  298.         cursor.execute(query)
  299.  
  300.         cnx.commit()
  301.     print "Logging transaction"
  302.     totalcount = 0
  303.     for i in items:
  304.         totalcount += i.qty
  305.     query = ("INSERT INTO transactions "
  306.              "(totalsale, items, transactiontype, paymentmethod, salestax, datetime, itemcount)"
  307.              "VALUES (%s, %s, %s, %s, %s, %s, %s)")
  308.     print "TOTAL: " + str(total)
  309.     data = (str(total), pickle.dumps(items), transactiontype, paymentmethod, str(subtotal * 0.07), d.strftime('%Y-%m-%d %H:%M:%S'), totalcount)
  310.     cursor.execute(query, data)
  311.     cnx.commit()
  312.  
  313. # Carry out task of confirm button based on the current menu
  314. def confirm():
  315.     global menu
  316.     global items
  317.     global keypadValue
  318.     global total
  319.     global registerTotal
  320.     global cursor
  321.     global cnx
  322.  
  323.     if menu == "Sale Quantity":
  324.         items[map(int, itemsListbox.curselection())[0]].qty = int(keypadValue)
  325.         updateItemsList()
  326.         keypad.place_forget()
  327.         confirmCancel.place_forget()
  328.         menu = "Sale"
  329.         menuSale.pack()
  330.     elif menu == "Sale Pay Cash":
  331.         cashreceived = keypadToCurrency(keypadValue)
  332.         tempstring = "Change Due: " + '${:,.2f}'.format(cashreceived - total)
  333.         if cashreceived > total:
  334.             keypad.place_forget()
  335.             confirmCancel.place_forget()
  336.             menuConfirmSale.pack()
  337.             labelChangeConfirm.config(text=tempstring)
  338.             menu = "Change Confirm"
  339.             confirmCancel.place(x=600, y=390)
  340.     elif menu == "Change Confirm":
  341.         registerTotal += total
  342.         logTransaction("SALE", "CASH")
  343.         menuConfirmSale.pack_forget()
  344.         confirmCancel.place_forget()
  345.         menu = "Main"
  346.         menuMain.pack()
  347.     elif menu == "Sale Pay Card":
  348.         logTransaction("SALE", "CARD")
  349.         menuConfirmSale.pack_forget()
  350.         confirmCancel.place_forget()
  351.         menuMain.pack()
  352.         menu = "Main"
  353.     elif menu == "Transactions":
  354.         menuTransactions.pack_forget()
  355.         menuTransactionDetail.pack()
  356.         updateTransactionDetailsList()
  357.         menu = "Transaction Details"
  358.     elif menu == "Ebay Sale":
  359.         for i in items:
  360.             query = ("UPDATE inventory SET qty = qty - " + str(i.qty) + " WHERE id='" + i.id + "'")
  361.             cursor.execute(query)
  362.             query = ("UPDATE inventory SET totalsold = totalsold + " + str(i.qty) + " WHERE id='" + i.id + "'")
  363.             cursor.execute(query)
  364.         cnx.commit()
  365.         confirmCancel.place_forget()
  366.         menuEbaySale.pack_forget()
  367.         menuMain.pack()
  368.         items = list()
  369.         updateEbaySaleList()
  370.         menu = "Main"
  371.  
  372. # Carry out cancel button task based on the current menu
  373. def cancel():
  374.     global menu
  375.  
  376.     keypad.place_forget()
  377.     confirmCancel.place_forget()
  378.  
  379.     if menu == "Sale Quantity" or menu == "Sale Pay Cash":
  380.         menu = "Sale"
  381.         menuSale.pack()
  382.  
  383.     if menu == "Sale Pay Card" or menu == "Change Confirm":
  384.         menu = "Sale"
  385.         menuConfirmSale.pack_forget()
  386.         menuSale.pack()
  387.  
  388.     if menu == "Transactions":
  389.         menu = "Main"
  390.         menuTransactions.pack_forget()
  391.         menuMain.pack()
  392.  
  393.     if menu == "Transaction Details":
  394.         menuTransactionDetail.pack_forget()
  395.         menuTransactions.pack()
  396.         confirmCancel.place(x=600, y=390)
  397.         menu = "Transactions"
  398.  
  399.     if menu == "Ebay Sale":
  400.         confirmCancel.place_forget()
  401.         menuEbaySale.pack_forget()
  402.         menuMain.pack()
  403.         menu = "Main"
  404.  
  405. # Void a sale in progress and return to main menu
  406. def saleMenuVoid():
  407.     global menu
  408.     global items
  409.     items = list()
  410.     menu = "Main"
  411.     menuSale.pack_forget()
  412.     menuMain.pack()
  413.  
  414. # Close the POS. WHY ISNT THIS FUCKING WORKING
  415. def closePOS():
  416.     global root
  417.     root.quit()
  418.     quit()
  419.  
  420. # Keypad buttons
  421. def keypadKey(num):
  422.     global keypadValue
  423.     keypadValue += str(num)
  424.     keypadUpdate()
  425.  
  426. # Keypad clear button
  427. def keypadClear():
  428.     global keypadValue
  429.     if len(keypadValue) > 1:
  430.         keypadValue = keypadValue[:len(keypadValue) - 1]
  431.     else:
  432.         keypadValue = ""
  433.     keypadUpdate()
  434.  
  435. # Updates the keypad display
  436. def keypadUpdate():
  437.     global keypadValue
  438.     global keypadMode
  439.     if keypadMode == "Currency":
  440.         keypadstring = "000"
  441.         if len(keypadValue) < 3:
  442.             keypadstring = "0" * (3 - len(keypadValue)) + keypadValue
  443.         elif keypadValue == "":
  444.             keypadstring = "0"
  445.         else:
  446.             keypadstring = keypadValue
  447.  
  448.         tempstring = "$" + keypadstring[0:len(keypadstring) - 2] + "." + keypadstring[
  449.                                                                          len(keypadstring) - 2:len(keypadstring)]
  450.     elif keypadMode == "Quantity":
  451.         tempstring = keypadValue
  452.         if tempstring == "":
  453.             tempstring = "0"
  454.  
  455.     keypadDisplay.config(text=tempstring)
  456.  
  457. # Updates the items list and (sub)total display
  458. def updateItemsList():
  459.     print "Updating item list"
  460.     global subtotal
  461.     global total
  462.     global taxrate
  463.     global totals
  464.     global items
  465.     subtotal = 0.0
  466.     total = 0.0
  467.     itemsListbox.delete(0,END)
  468.     for x in range(len(items)):
  469.         print "Adding item"
  470.         length = 18
  471.         itemName = items[x].name[:10]
  472.         itemNameLen = len(itemName)
  473.         itemQtyPrice = " " + str(items[x].qty) + " " + '${:,.2f}'.format(items[x].price)
  474.         for y in range(length - len(itemQtyPrice) - itemNameLen):
  475.             itemName += " "
  476.         itemName += itemQtyPrice
  477.         itemsListbox.insert(END, itemName)
  478.         subtotal += items[x].qty * items[x].price
  479.         subtotal = round(subtotal, 2)
  480.     total = round(subtotal * taxrate, 2)
  481.     tax = round(subtotal * 0.07, 2)
  482.     stringtemp = "Subtotal: " + '${:,.2f}'.format(subtotal) + "\nSales Tax: " + '${:,.2f}'.format(tax) +"\nTotal: " + '${:,.2f}'.format(total) + "\n"
  483.     textTotal.config(text = stringtemp)
  484.     itemsListbox.select_set(0)
  485.  
  486. # Updates the items list and (sub)total display
  487. def updateEbaySaleList():
  488.     global items
  489.     ebaySaleListbox.delete(0,END)
  490.     for x in range(len(items)):
  491.         print "Adding item"
  492.         length = 18
  493.         itemName = items[x].name[:10]
  494.         itemNameLen = len(itemName)
  495.         itemQtyPrice = " " + str(items[x].qty) + " " + '${:,.2f}'.format(items[x].price)
  496.         for y in range(length - len(itemQtyPrice) - itemNameLen):
  497.             itemName += " "
  498.         itemName += itemQtyPrice
  499.         ebaySaleListbox.insert(END, itemName)
  500.  
  501. # Updates the transaction details item list
  502. def updateTransactionDetailsList():
  503.     print "Updating item list"
  504.     global subtotal
  505.     global total
  506.     global taxrate
  507.     global totals
  508.     global items
  509.     global cursor
  510.     global cnx
  511.     global transactions
  512.  
  513.     subtotal = 0.0
  514.     total = 0.0
  515.     transactionDetailsListbox.delete(0, END)
  516.     items[:] = []
  517.     print "Total number of transactions: " + str(len(transactions))
  518.     i = transactions[map(int, transactionsListbox.curselection())[0]].id
  519.     i = transactions[map(int, transactionsListbox.curselection())[0]].id
  520.     query = ("SELECT totalsale, items, transactiontype, paymentmethod, salestax FROM transactions WHERE id = '" + str(i) + "'")
  521.     cursor.execute(query)
  522.     for (totalsale, items, transactiontype, paymentmethod, salestax) in cursor:
  523.         if transactiontype == "SALE":
  524.             items = pickle.loads(items)
  525.         else:
  526.             items = ""
  527.         print items
  528.  
  529.     for x in range(len(items)):
  530.         print "Adding item"
  531.         length = 18
  532.         itemName = items[x].name[:10]
  533.         itemNameLen = len(itemName)
  534.         itemQtyPrice = " " + str(items[x].qty) + " " + '${:,.2f}'.format(items[x].price)
  535.         for y in range(length - len(itemQtyPrice) - itemNameLen):
  536.             itemName += " "
  537.         itemName += itemQtyPrice
  538.         transactionDetailsListbox.insert(END, itemName)
  539.         subtotal += items[x].qty * items[x].price
  540.         subtotal = round(subtotal, 2)
  541.     total = round(subtotal * taxrate, 2)
  542.     tax = round(subtotal * 0.07, 2)
  543.     stringtemp = "Subtotal: " + '${:,.2f}'.format(subtotal) + "\nSales Tax: " + '${:,.2f}'.format(
  544.         tax) + "\nTotal: " + '${:,.2f}'.format(total) + "\n"
  545.     textTotal.config(text=stringtemp)
  546.  
  547. # Updates the transactions listbox
  548. def updateTransactionsListbox():
  549.     global cursor
  550.     global cnx
  551.     global transactions
  552.     transactions = list()
  553.     transactionsListbox.delete(0,END)
  554.     d = datetime.date.today()
  555.     query = ("SELECT id, totalsale, items, transactiontype, paymentmethod, salestax, itemcount FROM transactions WHERE date(datetime) >= date '" + d.strftime('%Y-%m-%d') + "' ORDER BY datetime DESC")
  556.     cursor.execute(query)
  557.     for (id, totalsale, items, transactiontype, paymentmethod, salestax, itemcount) in cursor:
  558.         t = transactiontype + "  "
  559.         t += paymentmethod + "  "
  560.         t += '{:2.0f}'.format(itemcount) + "  "
  561.         t += '${:,.2f}'.format(totalsale) + "  "
  562.         t += '${:,.2f}'.format(salestax) + "  "
  563.         transactionsListbox.insert(END, t)
  564.         newTransaction = transaction()
  565.         newTransaction.id = id
  566.         transactions.append(newTransaction)
  567.         print totalsale
  568.     transactionsListbox.select_set(0)
  569.  
  570. # List of today's transactions
  571. class transaction:
  572.     id = ""
  573. transactions = list()
  574.  
  575. # List of items currenty rung up for sale
  576. class item:
  577.     id =""
  578.     name = "Item Name"
  579.     qty = 1
  580.     price = 1.00
  581. items = list()
  582.  
  583. # Root tkinter widget
  584. root = Tk()
  585. root.geometry("800x480")
  586.  
  587. # Load Images
  588. pngDollar = Image.open("Dollar.png")
  589. iconDollar = ImageTk.PhotoImage(pngDollar)
  590. pngAdjustment = Image.open("Adjustment.png")
  591. iconAdjustment = ImageTk.PhotoImage(pngAdjustment)
  592. pngPower = Image.open("Power.png")
  593. iconPower = ImageTk.PhotoImage(pngPower)
  594. pngHistory = Image.open("History.png")
  595. iconHistory = ImageTk.PhotoImage(pngHistory)
  596. pngEbay = Image.open("Ebay.png")
  597. iconEbay = ImageTk.PhotoImage(pngEbay)
  598. pngKey = Image.open("Key.png")
  599. iconKey = ImageTk.PhotoImage(pngKey)
  600. pngButtonCash = Image.open("ButtonCash.png")
  601. iconButtonCash = ImageTk.PhotoImage(pngButtonCash)
  602. pngButtonCard = Image.open("ButtonCard.png")
  603. iconButtonCard = ImageTk.PhotoImage(pngButtonCard)
  604. pngButtonVoid = Image.open("ButtonVoid.png")
  605. iconButtonVoid = ImageTk.PhotoImage(pngButtonVoid)
  606. pngButtonLookup = Image.open("ButtonLookup.png")
  607. iconButtonLookup = ImageTk.PhotoImage(pngButtonLookup)
  608. pngButtonQuantity = Image.open("ButtonQuantity.png")
  609. iconButtonQuantity = ImageTk.PhotoImage(pngButtonQuantity)
  610. pngCheck = Image.open("Check.png")
  611. iconCheck = ImageTk.PhotoImage(pngCheck)
  612. pngCancel = Image.open("Cancel.png")
  613. iconCancel = ImageTk.PhotoImage(pngCancel)
  614. pngButtonBack = Image.open("ButtonBack.png")
  615. iconButtonBack = ImageTk.PhotoImage(pngButtonBack)
  616. pngButtonAdjustAdd = Image.open("ButtonAdjustAdd.png")
  617. iconButtonAdjustAdd = ImageTk.PhotoImage(pngButtonAdjustAdd)
  618. pngButtonAdjustSub = Image.open("ButtonAdjustSub.png")
  619. iconButtonAdjustSub = ImageTk.PhotoImage(pngButtonAdjustSub)
  620. pngButtonTools = Image.open("ButtonTools.png")
  621. iconButtonTools = ImageTk.PhotoImage(pngButtonTools)
  622. pngButtonAppliances = Image.open("ButtonAppliances.png")
  623. iconButtonAppliances = ImageTk.PhotoImage(pngButtonAppliances)
  624. pngButtonHousewares = Image.open("ButtonHousewares.png")
  625. iconButtonHousewares = ImageTk.PhotoImage(pngButtonHousewares)
  626. pngButtonMisc = Image.open("ButtonMisc.png")
  627. iconButtonMisc = ImageTk.PhotoImage(pngButtonMisc)
  628.  
  629. # Main Menu
  630. menuMain = Frame(root)
  631. menuMain.pack()
  632.  
  633. b1 = Button(menuMain, image=iconHistory, width=260, height=240, command=transactionsMenu).grid(row=1, column=1)
  634. b2 = Button(menuMain, image=iconEbay, width=260, height=240, command=ebaySaleMenu).grid(row=1, column=2)
  635. b3 = Button(menuMain, image=iconKey, width=260, height=240).grid(row=1, column=3)
  636. b4 = Button(menuMain, image=iconDollar, width=260, height=240, command=saleMenu).grid(row=2, column=1)
  637. b5 = Button(menuMain, image=iconAdjustment, width=260, height=240, command=adjustmentMenu).grid(row=2, column=2)
  638. b6 = Button(menuMain, image=iconPower, width=260, height=240, command=closePOS).grid(row=2, column=3)
  639.  
  640. # Sale Menu
  641. menuSale = Frame(root)
  642.  
  643. root.bind("<Key>", keyInput)
  644.  
  645. itemsWidth = 18
  646.  
  647. itemsListbox = Listbox(menuSale, selectmode=SINGLE, width=itemsWidth, height=11, font=("Courier", 30))
  648. itemsListbox.grid(row=1, column=1, rowspan=5)
  649.  
  650. textTotal = Label(menuSale, height=4, text="totals", font=("Courier", 16), justify=RIGHT)
  651. textTotal.grid(row=1, column=2, columnspan=2)
  652.  
  653. buttonGeneric = Button(menuSale, image=iconButtonLookup, command=genericItemMenu)
  654. buttonGeneric.grid(row = 2, column=2)
  655.  
  656. buttonQuantity = Button(menuSale, image=iconButtonQuantity, command=saleMenuQuantity)
  657. buttonQuantity.grid(row=2, column=3)
  658.  
  659. buttonCash = Button(menuSale, image=iconButtonCash, command=saleMenuPayCash)
  660. buttonCash.grid(row=3, column=2, columnspan=2)
  661.  
  662. buttonCard = Button(menuSale, image=iconButtonCard, command=saleMenuPayCard)
  663. buttonCard.grid(row=4, column=2, columnspan=2)
  664.  
  665. buttonVoid = Button(menuSale, image=iconButtonVoid, command=saleMenuVoid)
  666. buttonVoid.grid(row=5, column=2, columnspan=2)
  667.  
  668. # Transaction History Menu
  669. menuTransactions = Frame(root)
  670. transactionsLegend = Label(menuTransactions, width=30, height=1, font=("Courier", 30))
  671. transactionsLegend.config(text="TYPE       QTY  TOTAL   TAX   ")
  672. transactionsLegend.pack()
  673. transactionsListbox = Listbox(menuTransactions, width=30, height=7, font=("Courier", 30))
  674. transactionsListbox.pack()
  675.  
  676. # Transaction Detail Menu
  677. menuTransactionDetail = Frame(root)
  678. transactionDetailsListbox = Listbox(menuTransactionDetail, selectmode=SINGLE, width=itemsWidth, height=11, font=("Courier", 30))
  679. transactionDetailsListbox.grid(row=1, column=1, rowspan=5)
  680.  
  681. # Register Adjustment Menu
  682. menuAdjust = Frame(root)
  683.  
  684. itemsWidth = 18
  685.  
  686. blankListboxAdjust = Listbox(menuAdjust, selectmode=SINGLE, width=itemsWidth, height=11, font=("Courier", 30))
  687. blankListboxAdjust.grid(row=1, column=1, rowspan=4)
  688.  
  689. blankLabelAdjust = Label(menuAdjust,  height=5, font=("Courier", 30))
  690. blankLabelAdjust.grid(row=1, column=2)
  691.  
  692. buttonAdjustAdd = Button(menuAdjust, image=iconButtonAdjustAdd, command=adjustmentMenuAdd)
  693. buttonAdjustAdd.grid(row=2, column=2)
  694.  
  695. buttonAdjustSub = Button(menuAdjust, image=iconButtonAdjustSub, command=adjustmentMenuSub)
  696. buttonAdjustSub.grid(row=3, column=2)
  697.  
  698. buttonAdjustBack = Button(menuAdjust, image=iconButtonBack, command=adjustmentMenuBack)
  699. buttonAdjustBack.grid(row=4, column=2)
  700.  
  701. # Generic Item Menu
  702. menuGenericItem = Frame(root)
  703.  
  704. blankListboxGenericItem = Listbox(menuGenericItem, selectmode=SINGLE, width=itemsWidth, height=11, font=("Courier", 30))
  705. blankListboxGenericItem.grid(row=1, column=1, rowspan=4)
  706.  
  707. blankLabelGenericItem = Label(menuGenericItem,  height=5, font=("Courier", 30))
  708. blankLabelGenericItem.grid(row=1, column=2, columnspan=2)
  709.  
  710. buttonGenericTools = Button(menuGenericItem, image=iconButtonTools, command=lambda: addGenericItem("Tools"))
  711. buttonGenericTools.grid(row=2, column=2)
  712.  
  713. buttonGenericAppliances = Button(menuGenericItem, image=iconButtonAppliances, command=lambda: addGenericItem("Appliances"))
  714. buttonGenericAppliances.grid(row=2, column=3)
  715.  
  716. buttonGenericHousewares = Button(menuGenericItem, image=iconButtonHousewares, command=lambda: addGenericItem("Housewares"))
  717. buttonGenericHousewares.grid(row=3, column=2)
  718.  
  719. buttonGenericMisc = Button(menuGenericItem, image=iconButtonMisc, command=lambda: addGenericItem("Misc"))
  720. buttonGenericMisc.grid(row=3, column=3)
  721.  
  722. buttonGenericBack = Button(menuGenericItem, image=iconButtonBack, command=genericItemMenuBack)
  723. buttonGenericBack.grid(row=4, column=2, columnspan=2)
  724.  
  725. # Ebay Sale Menu
  726. menuEbaySale = Frame(root)
  727.  
  728. itemsWidth = 18
  729.  
  730. ebaySaleListbox = Listbox(menuEbaySale, selectmode=SINGLE, width=itemsWidth, height=11, font=("Courier", 30))
  731. ebaySaleListbox.grid(row=1, column=1, rowspan=5)
  732.  
  733. # Change Menu
  734. menuConfirmSale = Frame(root)
  735. labelChangeConfirm = Label(menuConfirmSale, text="", font=("Courier", 40))
  736. labelChangeConfirm.grid(row=1, column=1)
  737.  
  738. # Keypad
  739. keypad = Frame(root, borderwidth=2)
  740.  
  741. keypadDisplay = Label(keypad, text="$0.00", font=("Courier", 40), background="#ffffff", width=12, anchor=E)
  742. keypadDisplay.grid(row=1, column=1, columnspan=3, sticky=E)
  743.  
  744. keyFontSize = 40;
  745. keyWidth = 4
  746.  
  747. kp7 = Button(keypad, text="7", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(7))
  748. kp7.grid(row=2, column=1)
  749.  
  750. kp8 = Button(keypad, text="8", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(8))
  751. kp8.grid(row=2, column=2)
  752.  
  753. kp9 = Button(keypad, text="9", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(9))
  754. kp9.grid(row=2, column=3)
  755.  
  756. kp4 = Button(keypad, text="4", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(4))
  757. kp4.grid(row=3, column=1)
  758.  
  759. kp5 = Button(keypad, text="5", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(5))
  760. kp5.grid(row=3, column=2)
  761.  
  762. kp6 = Button(keypad, text="6", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(6))
  763. kp6.grid(row=3, column=3)
  764.  
  765. kp1 = Button(keypad, text="1", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(1))
  766. kp1.grid(row=4, column=1)
  767.  
  768. kp2 = Button(keypad, text="2", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(2))
  769. kp2.grid(row=4, column=2)
  770.  
  771. kp3 = Button(keypad, text="3", font=("Courier", keyFontSize), width=keyWidth, command=lambda: keypadKey(3))
  772. kp3.grid(row=4, column=3)
  773.  
  774. kp0 = Button(keypad, text="0", font=("Courier", keyFontSize), width=(keyWidth * 2), command=lambda: keypadKey(0))
  775. kp0.grid(row=5, column=1, columnspan=2)
  776.  
  777. kpBack = Button(keypad, text="<", font=("Courier", keyFontSize), width=keyWidth, command=keypadClear)
  778. kpBack.grid(row=5, column=3)
  779.  
  780. # Confirm/Cancel
  781. confirmCancel = Frame(root)
  782.  
  783. buttonConfirm = Button(confirmCancel, image=iconCheck, command=confirm)
  784. buttonConfirm.grid(row=1, column=1)
  785. buttonCancel = Button(confirmCancel, image=iconCancel, command=cancel)
  786. buttonCancel.grid(row=1, column=2)
  787.  
  788. updateItemsList()
  789.  
  790. # Enter tkinter's main loop
  791. root.mainloop()
Add Comment
Please, Sign In to add comment