Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- import time #import tkinter and time modules
- from tkinter import *
- def attendance(): #define attendance function
- aWindow = Toplevel(root) #create a new window with root window as parent
- aWindow.title("Attendance Details") #title for new window
- def validate(): #inside the attendance function define a validation function for the validate button
- global session1
- global session2
- global session3
- global session4
- #make the adult and child variables global so they can be used in the other functions
- session1 = [int(entAdult1.get()),int(entChild1.get())]
- session2 = [int(entAdult2.get()),int(entChild2.get())]
- session3 = [int(entAdult3.get()),int(entChild3.get())]
- session4 = [int(entAdult4.get()),int(entChild4.get())] #these are arrays that only exist to fill task requirements, but I suppose it saves a few lines of code anway
- #makes the final variables the text from the child and adult entry classes
- if session1[0] >= -1 and session1[1] >= -1 and session2[0] >= -1 and session2[1] >= -1 and session3[0] >= -1 and session3[1] >= -1 and session4[0] >= -1 and session1[1] >= -1: #checks to see if the values are above zero
- valid.config(text=("CONFIRMED")) #if they are change the valid lable text to CONFIRMED
- btnCloseA.config(state="normal") #makes the exit button clickable
- b2.config(state="normal") #enables the revenue button on the mainwindow to be clickable
- else: #if the values are below zero then:
- valid.config(text="please enter numbers greater than or equal to zero") #makes the valid label complain
- btnCloseA.config(state="disabled") #if the exit button is clickable makes it unclickable
- def validate2(event): #inside the attendance function define a validation function for the validate button
- global session1
- global session2
- global session3
- global session4
- #make the adult and child variables global so they can be used in the other functions
- session1 = [int(entAdult1.get()),int(entChild1.get())]
- session2 = [int(entAdult2.get()),int(entChild2.get())]
- session3 = [int(entAdult3.get()),int(entChild3.get())]
- session4 = [int(entAdult4.get()),int(entChild4.get())] #these are arrays that only exist to fill task requirements, but I suppose it saves a few lines of code anway
- #makes the final variables the text from the child and adult entry classes
- if session1[0] >= -1 and session1[1] >= -1 and session2[0] >= -1 and session2[1] >= -1 and session3[0] >= -1 and session3[1] >= -1 and session4[0] >= -1 and session1[1] >= -1: #checks to see if the values are above zero
- valid.config(text=("CONFIRMED")) #if they are change the valid lable text to CONFIRMED
- btnCloseA.config(state="normal") #makes the exit button clickable
- b2.config(state="normal") #enables the revenue button on the mainwindow to be clickable
- else: #if the values are below zero then:
- valid.config(text="please enter numbers greater than or equal to zero") #makes the valid label complain
- btnCloseA.config(state="disabled") #if the exit button is clickable makes it unclickable
- adult1 = IntVar()
- child1 = IntVar()
- adult2 = IntVar()
- child2 = IntVar()
- adult3 = IntVar()
- child3 = IntVar()
- adult4 = IntVar()
- child4 = IntVar()
- def clearAdult1(event):
- entAdult1.selection_range(0,END)
- def clearAdult2(event):
- entAdult2.selection_range(0,END)
- def clearAdult3(event):
- entAdult3.selection_range(0,END)
- def clearAdult4(event):
- entAdult4.selection_range(0,END)
- def clearChild1(event):
- entChild1.selection_range(0,END)
- def clearChild2(event):
- entChild2.selection_range(0,END)
- def clearChild3(event):
- entChild3.selection_range(0,END)
- def clearChild4(event):
- entChild4.selection_range(0,END) #all the stuff that makes it so you only have to click once instead of twice to select, enjoy it
- #makes the adult and child entries integer values
- labAdult1 = Label(aWindow, text="S1 Adults:")
- labAdult1.grid(row=0, sticky=W)
- labChild1 = Label(aWindow, text="S1 Children:")
- labChild1.grid(row=1, sticky=W) #creates and positions the text
- entAdult1 = Entry(aWindow, validate="key", textvariable=adult1)
- entAdult1.grid(row=0, column=1)
- entChild1 = Entry(aWindow, validate="key", textvariable=child1)
- entChild1.grid(row=1, column=1) #creates and positions the entries
- Label(aWindow, text=" ").grid(row=2)
- entAdult1.bind("<FocusIn>",clearAdult1)
- entChild1.bind("<FocusIn>",clearChild1) #more stuff that makes the select thing work when the entry is given focus
- labAdult2 = Label(aWindow, text="S2 Adults:")
- labAdult2.grid(row=3, sticky=W)
- labChild2 = Label(aWindow, text="S2 Children:")
- labChild2.grid(row=4, sticky=W) #creates and positions the text
- entAdult2 = Entry(aWindow, validate="key", textvariable=adult2)
- entAdult2.grid(row=3, column=1)
- entChild2 = Entry(aWindow, validate="key", textvariable=child2)
- entChild2.grid(row=4, column=1) #creates and positions the entries
- Label(aWindow, text=" ").grid(row=5)
- entAdult2.bind("<FocusIn>",clearAdult2)
- entChild2.bind("<FocusIn>",clearChild2)
- labAdult3 = Label(aWindow, text="S3 Adults:")
- labAdult3.grid(row=6, sticky=W)
- labChild3 = Label(aWindow, text="S3 Children:")
- labChild3.grid(row=7, sticky=W) #creates and positions the text
- entAdult3 = Entry(aWindow, validate="key", textvariable=adult3)
- entAdult3.grid(row=6, column=1)
- entChild3 = Entry(aWindow, validate="key", textvariable=child3)
- entChild3.grid(row=7, column=1) #creates and positions the entries
- Label(aWindow, text=" ").grid(row=8)
- entAdult3.bind("<FocusIn>",clearAdult3)
- entChild3.bind("<FocusIn>",clearChild3)
- labAdult4 = Label(aWindow, text="S4 Adults:")
- labAdult4.grid(row=9, sticky=W)
- labChild4 = Label(aWindow, text="S5 Children:")
- labChild4.grid(row=10, sticky=W) #creates and positions the text
- entAdult4 = Entry(aWindow, validate="key", textvariable=adult4)
- entAdult4.grid(row=9, column=1)
- entChild4 = Entry(aWindow, validate="key", textvariable=child4)
- entChild4.grid(row=10, column=1) #creates and positions the entries
- Label(aWindow, text=" ").grid(row=11)
- entAdult4.bind("<FocusIn>",clearAdult4)
- entChild4.bind("<FocusIn>",clearChild4)
- btnCloseA = Button(aWindow, text="EXIT", fg="red",state = DISABLED, command = aWindow.destroy, padx = 30,)
- btnCloseA.grid(row=0 ,column=2, rowspan = 2, columnspan=2, sticky=N)
- btnValid = Button(aWindow, text="Validate", state = NORMAL, padx = 20, command=validate)
- btnValid.grid(row=1, column=2, rowspan = 2, columnspan=2, sticky=S) #creates and positions the buttons
- valid = Label(aWindow, text = "STANDBY...")
- valid.grid(row=12, columnspan=99, sticky=W) #creates and positions the valid text
- aWindow.bind("<Return>",validate2)
- def revenue(): #create the revenue function
- bWindow = Toplevel(root) #new window
- labDisplay1 = Label(bWindow, text=("adult total: "+str(session1[0]+session2[0]+session3[0]+session4[0])+" child total: "+str(session1[1]+session2[1]+session3[1]+session4[1]))) #label that displays the adult and child values defined in the other function
- labDisplay1.grid(row=0)
- labPriceA = Label(bWindow, text = "Adult price: $15")
- labPriceA.grid(row=1)
- labPriceB = Label(bWindow, text = "Child price: $8")
- labPriceB.grid(row=2)
- labResult1 = Label(bWindow, text = ("Money made S1: $" + str((session1[0]*15)+(session1[1]*8)))) #does the calculations
- labResult1.grid(row=3)
- Label(bWindow, text = " ").grid(row=4)
- labResult2 = Label(bWindow, text = ("Money made S2: $" + str((session2[0]*15)+(session2[1]*8)))) #does the calculations
- labResult2.grid(row=5)
- Label(bWindow, text = " ").grid(row=6)
- labResult3 = Label(bWindow, text = ("Money made S3: $" + str((session3[0]*15)+(session3[1]*8)))) #does the calculations
- labResult3.grid(row=7)
- Label(bWindow, text = " ").grid(row=8)
- labResult4 = Label(bWindow, text = ("Money made S4: $" + str((session4[0]*15)+(session4[1]*8)))) #does the calculations
- labResult4.grid(row=9)
- Label(bWindow, text = " ").grid(row=10)
- labTotal = Label(bWindow, text =("Total Money made: $" + str((session1[0]*15)+(session1[1]*8+(session2[0]*15)+(session2[1]*8)+session3[0]*15)+(session3[1]*8+session4[0]*15)+(session4[1]*8))))
- labTotal.grid(row=11)
- labDate = Label(bWindow, text =(time.strftime("%d/%m/%y")))
- labDate.grid(row=12) #creates and positions text
- Button(bWindow, text="CLOSE", fg="red", command=bWindow.destroy).grid(row=13)
- def exitcomm(): #defines exit command
- cWindow = Toplevel(root) #new window
- labExit = Label(cWindow, text = "are you sure you want to exit?")
- labExit.pack() #creates and positions text
- btnYes = Button(cWindow, text ="YES", command =root.destroy, fg="red")
- btnYes.pack()
- btnNo= Button(cWindow, text = "CANCEL", command =cWindow.destroy)
- btnNo.pack() #creates and positions button
- root = Tk() #creates the main window
- root.title("Cinema Management Menu") #title of mainwindow
- root.maxsize(width=600, height=350)
- root.minsize(width=600, height=350) #specifies maximum and minimum size in pixels
- welcome = Label(root, text = "Cinema Management Software Menu", font=("Cambria", 28)) #text with text size
- welcome.pack()
- Label(root, text = "By Gryff and Ben",).place(x = 300, y= 325, anchor= CENTER)
- b1 = Button(root, text ="Attendance Details",padx=50, pady=25, command=attendance)
- b1.place(x =175 , y = 100, anchor = CENTER)
- b2 = Button(root, text ="Revenue Stastics", command=revenue, padx=50, pady=25, state=DISABLED)
- b2.place(x =425, y = 100, anchor = CENTER)
- b3 = Button(root, text ="EXIT", fg = "red", command =exitcomm, padx=50, pady=25)
- b3.place(x = 300, y =200, anchor = CENTER) #places and creates buttons and text
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement