Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import random
- import time
- from PyQt5 import QtGui
- #===================DAT BASE=================================
- import sqlite3
- conn = sqlite3.connect('inventory .db')
- c= conn.cursor()
- print ("Opened database successfully");
- #==========================================
- root = Tk()
- root.geometry("1600x700+0+0")
- root.title("POINT OF SALE SYSTEM JAMIA MILLIA ISLAMIA ")
- Tops = Frame(root,bg="white",width = 1600,height=50,relief=SUNKEN)
- Tops.pack(side=TOP)
- f1 = Frame(root,width = 900,height=700,relief=SUNKEN)
- f1.pack(side=LEFT)
- f2 = Frame(root ,width = 400,height=700,relief=SUNKEN)
- f2.pack(side=RIGHT)
- #------------------TIME--------------
- localtime=time.asctime(time.localtime(time.time()))
- #-----------------INFO TOP-----------------
- lblinfo = Label(Tops, font=( 'aria' ,30, 'bold' ),text="POINT OF SALE SYSTEM JAMIA MILLIA ISLAMIA " ,fg="GREEN",bd=10,anchor='w')
- lblinfo.grid(row=0,column=0)
- lblinfo = Label(Tops, font=( 'aria' ,20, ),text=localtime,fg="GREEN",anchor=W)
- lblinfo.grid(row=0,column=1)
- #=================================================================log in ====================================================================
- creds = 'tempfile.temp'
- def Signup(): # This is the signup definition,
- global pwordE # These globals just make the variables global to the entire script, meaning any definition can use them
- global nameE
- global roots
- roots = Tk() # This creates the window, just a blank one.
- roots.title('Signup') # This renames the title of said window to 'signup'
- intruction = Label(roots, text='JAMIA MILLIA ISLAMIA \n') # This puts a label, so just a piece of text saying 'please enter blah'
- intruction.grid(row=0, column=0, sticky=E) # This just puts it in the window, on row 0, col 0. If you want to learn more look up a tkinter tutorial :)
- nameL = Label(roots, text='New Username: ') # This just does the same as above, instead with the text new username.
- pwordL = Label(roots, text='New Password: ') # ^^
- nameL.grid(row=1, column=0, sticky=W) # Same thing as the instruction var just on different rows. :) Tkinter is like that.
- pwordL.grid(row=2, column=0, sticky=W) # ^^
- nameE = Entry(roots) # This now puts a text box waiting for input.
- pwordE = Entry(roots, show='*') # Same as above, yet 'show="*"' What this does is replace the text with *, like a password box :D
- nameE.grid(row=1, column=1) # You know what this does now :D
- pwordE.grid(row=2, column=1) # ^^
- signupButton = Button(roots, text='Signup', command=FSSignup) # This creates the button with the text 'signup', when you click it, the command 'fssignup' will run. which is the def
- signupButton.grid(columnspan=2, sticky=W)
- roots.mainloop() # This just makes the window keep open, we will destroy it soon
- def FSSignup():
- with open(creds, 'w') as f: # Creates a document using the variable we made at the top.
- f.write(nameE.get()) # nameE is the variable we were storing the input to. Tkinter makes us use .get() to get the actual string.
- f.write('\n') # Splits the line so both variables are on different lines.
- f.write(pwordE.get()) # Same as nameE just with pword var
- f.close() # Closes the file
- roots.destroy() # This will destroy the signup window. :)
- Login() # This will move us onto the login definition :D
- def Login():
- global nameEL
- global pwordEL # More globals :D
- global rootA
- rootA = Tk() # This now makes a new window.
- rootA.title('Login') # This makes the window title 'login'
- intruction = Label(rootA, text='Please Login\n') # More labels to tell us what they do
- intruction.grid(sticky=E) # Blahdy Blah
- nameL = Label(rootA, text='Username: ') # More labels
- pwordL = Label(rootA, text='Password: ') # ^
- nameL.grid(row=1, insertwidth=4,sticky=W)
- pwordL.grid(row=2, sticky=W)
- nameEL = Entry(rootA) # The entry input
- pwordEL = Entry(rootA, show='*')
- nameEL.grid(row=1, column=1)
- pwordEL.grid(row=2, column=1)
- # loginB = Button(rootA, text='Login', command=CheckLogin) # This makes the login button, which will go to the CheckLogin def.
- #loginB.grid(columnspan=8, sticky=W)
- rmuser = Button(rootA, text='Delete User', fg='red', command=DelUser) # This makes the deluser button. blah go to the deluser def.
- rmuser.grid(columnspan=8, sticky=W)
- rootA.mainloop()
- def CheckLogin():
- with open(creds) as f:
- data = f.readlines() # This takes the entire document we put the info into and puts it into the data variable
- uname = data[0].rstrip() # Data[0], 0 is the first line, 1 is the second and so on.
- pword = data[1].rstrip() # Using .rstrip() will remove the \n (new line) word from before when we input it
- if nameEL.get() == uname and pwordEL.get() == pword: # Checks to see if you entered the correct data.
- r = Tk() # Opens new window
- r.title(':D')
- r.geometry("600x700+0+0") # Makes the window a certain size
- rlbl = Label(r, text='\n[+] Logged In') # "logged in" label
- rlbl.pack() # Pack is like .grid(), just different
- r.mainloop()
- else:
- r = Tk()
- r.title('D:')
- r.geometry("600x700+0+0")
- rlbl = Label(r, text='\n[!] Invalid Login')
- rlbl.pack()
- r.mainloop()
- def DelUser():
- os.remove(creds) # Removes the file
- rootA.destroy() # Destroys the login window
- Signup() # And goes back to the start!
- def os():
- if os.path.isfile(creds):
- Login()
- else: # This if else statement checks to see if the file exists. If it does it will go to Login, if not it will go to Signup :)
- Signup()
- #=======================================================================================
- def __init__(self, pos):
- super(Application, self).__init__(pos)
- self.task = ""
- self.UserIn = StringVar()
- self.grid()
- self.create_widgets()
- text_Input=StringVar()
- operator =""
- txtdisplay = Entry(f2,font=('ariel' ,390,'bold'), textvariable=text_Input, bd=4 ,insertwidth=24 ,bg="white",justify='right')
- txtdisplay.grid(columnspan=40 )
- def btnclick(numbers):
- global operator
- operator=operator + str(numbers)
- text_Input.set(operator)
- def clrdisplay():
- global operator
- operator=""
- text_Input.set("")
- def eqals():
- global operator
- sumup=str(eval(operator))
- text_Input.set(sumup)
- operator = ""
- def Ref():
- x=random.randint(12980, 50876)
- randomRef = str(x)
- rand.set(randomRef)
- cof =float(Fries.get())
- colfries= float(Largefries.get())
- cob= float(Burger.get())
- cofi= float(Filet.get())
- cochee= float(Cheese_burger.get())
- codr= float(Drinks.get())
- costoffries = cof*25
- costoflargefries = colfries*40
- costofburger = cob*35
- costoffilet = cofi*50
- costofcheeseburger = cochee*50
- costofdrinks = codr*35
- costofmeal = "Rs.",str('%.2f'% (costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks))
- PayTax=((costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)*0.33)
- Totalcost=(costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)
- Ser_Charge=((costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)/99)
- Service="Rs.",str('%.2f'% Ser_Charge)
- OverAllCost="Rs.",str( PayTax + Totalcost + Ser_Charge)
- PaidTax="Rs.",str('%.2f'% PayTax)
- Service_Charge.set(Service)
- cost.set(costofmeal)
- Tax.set(PaidTax)
- Subtotal.set(costofmeal)
- Total.set(OverAllCost)
- #btnTotal=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="TOTAL", bg="#E6D72A",command=Ref)
- #btnTotal.grid(row=7, column=1)
- def qexit():
- root.destroy()
- def reset():
- rand.set("")
- Fries.set("")
- Largefries.set("")
- Burger.set("")
- Filet.set("")
- Subtotal.set("")
- Total.set("")
- Service_Charge.set("")
- Drinks.set("")
- Tax.set("")
- cost.set("")
- Cheese_burger.set("")
- def __init__(self, master):
- super(Application, self).__init__(master)
- self.task = ""
- self.UserIn = StringVar()
- self.grid()
- self.create_widgets()
- def displayText(self, value):
- self.user_input.delete(0, END)
- self.user_input.insert(0, value)
- #---------------------------------------------------------------------------------------
- rand = StringVar()
- Fries = StringVar()
- Largefries = StringVar()
- Burger = StringVar()
- Filet = StringVar()
- Subtotal = StringVar()
- Total = StringVar()
- Service_Charge = StringVar()
- Drinks = StringVar()
- Tax = StringVar()
- cost = StringVar()
- Cheese_burger = StringVar()
- def create_widgets(self):
- # self.button2 = Button(self, bg = "#98DBC6", bd = 12,
- # text = "Fries Meal", padx = 35, pady = 8,
- #command = lambda: self.buttonClick("Lunch"), font = ("Helvetica", 20, "bold"))
- #self.button2.grid(row = 2, column = 1, sticky = W)
- #self.button1 = Button(self, bg = "#98DBC6", bd = 12,
- #text = "samosa", padx = 33, pady = 7, font = ("Helvetica", 20, "bold"),
- #command = lambda : self.buttonClick("samosa"))
- #self.button1.grid(row = 2, column = 0, sticky = W)
- #self.button1 = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Lunch Meal",fg="steel blue",bd=10,anchor='w')
- #self.button1.grid(row=2,column=0)
- #lblfries = Button(f1, font=( 'aria' ,16, 'bold' ),text="Fries Meal",fg="steel blue",bd=10,anchor='w')
- #lblfries.grid(row=1,column=0)
- #txtfries = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Fries , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
- #txtfries.grid(row=1,column=1)
- lblreference = Label(f1, font=( 'aria' ,16, 'bold' ),text="Order No.",fg="steel blue",bd=10,anchor='w')
- lblreference.grid(row=0,column=0)
- txtreference = Entry(f1,font=('ariel' ,16,'bold'), textvariable=rand , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
- txtreference.grid(row=0,column=1)
- #def(self):
- # lblLargefries = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Lunch Meal",fg="steel blue",bd=10,anchor='w',command=self.Lunch )
- # lblLargefries.grid(row=9,column=0)
- lblburger = Button(f1, font=( 'aria' ,16, 'bold' ),text="Burger Meal",fg="steel blue",bd=10,anchor='w')
- lblburger.grid(row=3,column=0)
- txtburger = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Burger , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
- txtburger.grid(row=3,column=1)
- lblFilet = Button(f1, font=( 'aria' ,16, 'bold' ),text="Pizza Meal",fg="steel blue",bd=10,anchor='w')
- lblFilet.grid(row=4,column=0)
- txtFilet = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Filet , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
- txtFilet.grid(row=4,column=1)
- lblCheese_burger = Button(f1, font=( 'aria' ,16, 'bold' ),text="Cheese burger",fg="steel blue",bd=10,anchor='w')
- lblCheese_burger.grid(row=5,column=0)
- txtCheese_burger = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Cheese_burger , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
- txtCheese_burger.grid(row=5,column=1)
- #--------------------------------------------------------------------------------------
- #lblDrinks = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Drinks",fg="steel blue",bd=10,anchor='w')
- #lblDrinks.grid(row=0,column=2)
- #txtDrinks = buttonClick
- #lblDrinks.grid(row=0,column=4)
- #btn7=Button(f2,padx=16,pady=16,bd=4, fg="black", font=('ariel', 20 ,'bold'),text="7",bg="powder blue", command=lambda: btnclick(7) )
- #btn7.grid(row=2,column=0)
- lblcost = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="cost",fg="steel blue",bd=10,anchor='w')
- lblcost.grid(row=9,column=7)
- lblService_Charge = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Service Charge",fg="steel blue",bd=10,anchor='w')
- lblService_Charge.grid(row=5,column=4)
- #lblTax = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Tax",fg="steel blue",bd=10,anchor='w')
- #lblTax.grid(row=5,column=2)
- #txtTax = buttonClick
- lblSubtotal = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Subtotal",fg="steel blue",bd=10,anchor='w')
- lblSubtotal.grid(row=9,column=3)
- lblTotal = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Total",fg="steel blue",bd=10,anchor='w')
- lblTotal.grid(row=10,column=10)
- #btn=Button(f2,padx=16,pady=16,bd=4, fg="black", font=('Helvetica', 20 ,'bold'),text="Lunch ",bg="powder blue", command=lambda: btnclick(Lunch ) )
- #btn.grid(row=8,column=0)
- #-----------------------------------------buttons------------------------------------------
- lblTotal = Label(f1,text="---------------------",fg="white")
- lblTotal.grid(row=8,columnspan=3)
- btnTotal=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="TOTAL", bg="#E6D72A",command=Ref)
- btnTotal.grid(row=7, column=1)
- btnreset=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="RESET", bg="#E6D72A",command=reset)
- btnreset.grid(row=7, column=2)
- btnexit=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('ariel' ,16,'bold'),width=10, text=" LOG-IN ", bg="#E6D72A",command='CheckLogin')
- btnexit.grid(row=7, column=0)
- def price():
- roo = Tk()
- roo.geometry("600x220+0+0")
- roo.title("Price List")
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="ITEM", fg="black", bd=5)
- lblinfo.grid(row=0, column=0)
- lblinfo = Label(roo, font=('aria', 15,'bold'), text="_____________", fg="white", anchor=W)
- lblinfo.grid(row=0, column=2)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="PRICE", fg="black", anchor=W)
- lblinfo.grid(row=0, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Fries Meal", fg="steel blue", anchor=W)
- lblinfo.grid(row=1, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="25", fg="steel blue", anchor=W)
- lblinfo.grid(row=1, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Lunch Meal", fg="steel blue", anchor=W)
- lblinfo.grid(row=2, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="40", fg="steel blue", anchor=W)
- lblinfo.grid(row=2, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Burger Meal", fg="steel blue", anchor=W)
- lblinfo.grid(row=3, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="35", fg="steel blue", anchor=W)
- lblinfo.grid(row=3, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Pizza Meal", fg="steel blue", anchor=W)
- lblinfo.grid(row=4, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="50", fg="steel blue", anchor=W)
- lblinfo.grid(row=4, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Cheese Burger", fg="steel blue", anchor=W)
- lblinfo.grid(row=5, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="30", fg="steel blue", anchor=W)
- lblinfo.grid(row=5, column=3)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Drinks", fg="steel blue", anchor=W)
- lblinfo.grid(row=6, column=0)
- lblinfo = Label(roo, font=('aria', 15, 'bold'), text="35", fg="steel blue", anchor=W)
- lblinfo.grid(row=6, column=3)
- roo.mainloop()
- root.mainloop()
Add Comment
Please, Sign In to add comment