Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Tkinter import*
- from tkMessageBox import*
- import os
- import random
- Interface = Tk()
- Interface.resizable(0,0)
- global Vote_Reroll
- def Homepage():
- global Username_Input
- global Password_Input
- Interface.title ("Cyber Roll")
- Interface.geometry("400x200")
- Hello=Label(Interface,text="Welcome to Cyber Roll",font = "Helvetica 10 bold ")
- Hello.place(x=145,y=5)
- Username = Label(Interface,text="Username: ")
- Username.place(x=20,y=40)
- Username_Input = Entry(Interface,width=45)
- Username_Input.place(x=100,y=40)
- Password = Label(Interface,text="Password: ")
- Password.place(x=20,y=70)
- Password_Input = Entry(Interface,width=45,show="*")
- Password_Input.place(x=100,y=70)
- Login = Button(Interface,width=15,text="Login",command=LoginModule)
- Login.place(x=50,y=100)
- Sign_Up = Button(Interface,width=15,text="Sign Up",command=SignUpModule)
- Sign_Up.place(x=240,y=100)
- def LoginModule():
- CompareUser = Username_Input.get()
- ComparePassword = Password_Input.get()
- OpeningAccount = open('account.txt', 'r')
- Line1 = next(OpeningAccount)
- AccountList = Line1.split(":")
- Line2 = next(OpeningAccount)
- PasswordList = Line2.split(",")
- OpeningAccount.close()
- Counter = 0
- MaxCounter = len(AccountList)
- while (Counter < MaxCounter):
- if (CompareUser == AccountList[Counter] and ComparePassword == PasswordList[Counter]):
- MenuModule()
- Counter = MaxCounter+1
- else:
- Counter+=1
- if (Counter == MaxCounter):
- showinfo ("System Info", "No such account! Please try again!")
- Homepage()
- CompareUser = ""
- ComparePassword = ""
- def MenuModule():
- global Halal_V
- global NonHalal_V
- global Ppl_Num_Input
- global Menu
- Halal_V = IntVar()
- NonHalal_V = IntVar()
- Interface.withdraw()
- Menu = Toplevel()
- Menu.title("Cyber Roll")
- Menu.geometry("300x200")
- Menu.resizable(0,0)
- Title = Label(Menu,text="Cyber Roll - Menu")
- Title.place(x=20,y=0)
- Halal = Checkbutton(Menu,text="Halal",variable=Halal_V)
- Halal.place(x=20,y=40)
- Non_Halal = Checkbutton(Menu,text="Non - Halal",variable=NonHalal_V)
- Non_Halal.place(x=20,y=70)
- Ppl_Num=Label(Menu,text="Number of People: ")
- Ppl_Num.place(x=20,y=100)
- Ppl_Num_Input = Entry(Menu,width=20)
- Ppl_Num_Input.place(x=130,y=100)
- Roll = Button(Menu,width=15,text="Roll",command=CheckSum)
- Roll.place(x=100,y=140)
- def PickingRestaurant():
- global Selected
- global SelectedRestaurantAddress
- if Halal_V.get()==1 and NonHalal_V.get()==0:
- HalalList = open("halal.txt", 'r')
- HalalLine1 = next(HalalList) #cause we only splitting line 1, important note
- HalalRestaurant = HalalLine1.split(":")
- Selected = random.choice(HalalRestaurant)
- HalalList.close()
- HalalList = open("halal.txt", 'r')
- next(HalalList)
- for iterator in HalalList:
- RestaurantInfo = iterator.split(":")
- RestaurantName = RestaurantInfo[0]
- RestaurantAddress = RestaurantInfo[1]
- if (RestaurantName == Selected):
- SelectedRestaurantAddress = RestaurantAddress
- Printing()
- else:
- pass
- elif NonHalal_V.get() == 1 and Halal_V.get()==0:
- NonHalalList = open("nonhalal.txt", 'r')
- NonHalalLine1 = next(NonHalalList) # cause we only splitting line 1, important note
- NonHalalRestaurant = NonHalalLine1.split(":")
- Selected = random.choice(NonHalalRestaurant)
- NonHalalList.close()
- NonHalalList = open("nonhalal.txt", 'r')
- next(NonHalalList)
- for iterator in NonHalalList:
- RestaurantInfo = iterator.split(":")
- print RestaurantInfo[0]
- RestaurantName = RestaurantInfo[0]
- RestaurantAddress = RestaurantInfo[1]
- if (RestaurantName == Selected):
- SelectedRestaurantAddress = RestaurantAddress
- Printing()
- else:
- pass
- elif NonHalal_V.get() == 1 and Halal_V.get()==1:
- NonHalalList = open("nonhalal.txt", 'r')
- HalalList = open("halal.txt", 'r')
- NonHalalLine1 = next(NonHalalList) # cause we only splitting line 1, important note
- HalalLine1 = next(HalalList) # cause we only splitting line 1, important note
- NonHalalRestaurant = NonHalalLine1.split(":")
- HalalRestaurant = HalalLine1.split(":")
- AllRestaurant = HalalRestaurant + NonHalalRestaurant # Combine
- Selected = random.choice(AllRestaurant) # randomg selecting
- NonHalalList.close() # closing these two to avoid any trouble on reading again
- HalalList.close() # closing these two to avoid any trouble on reading again.
- NonHalalList = open("nonhalal.txt", 'r')
- HalalList = open("halal.txt", 'r')
- next(NonHalalList)
- next(HalalList)
- for iterator in NonHalalList:
- NonHalalRestaurantInfo = iterator.split(":")
- if Selected == NonHalalRestaurantInfo[0]:
- SelectedRestaurantAddress= NonHalalRestaurantInfo[1]
- else:
- pass
- for iterator in HalalList:
- HalalRestaurantInfo = iterator.split(":")
- if Selected == HalalRestaurantInfo[0]:
- SelectedRestaurantAddress = HalalRestaurantInfo[1]
- else:
- pass
- Printing()
- else:
- showinfo("System Info", "Warning: System detected you pick nothing ! Please pick so")
- def Printing():
- global Menu2
- global Vote_Reroll
- global RestaurantInfo
- Menu2 = Toplevel()
- Menu2.title("Cyber Roll")
- Menu2.geometry("500x200")
- Menu2.resizable(0,0)
- Menu.withdraw()
- title = Label(Menu2, text="Cyber Roll - Menu")
- title.place(x=20, y=0)
- Rec_Restaurant = Label(Menu2, text="Recommended Restaurant: ")
- Rec_Restaurant.place(x=20, y=40)
- Rec_Restaurant_Label = Label(Menu2, text=Selected)
- Rec_Restaurant_Label.place(x=260, y=40)
- Vote = Label(Menu2, text="Vote to Reroll: ")
- Vote.place(x=20, y=70)
- Vote_Reroll = Entry(Menu2, width=45)
- Vote_Reroll.place(x=180, y=70)
- RestaurantInfoButton = Button(Menu2, text="Resturant\n info", width=15, command=PrintRestInfoModule)
- RestaurantInfoButton.place(x=80, y=120)
- Reroll = Button(Menu2, text="Re-Roll\n", width=15, command=CheckSum)
- Reroll.place(x=200, y=120)
- Accept = Button(Menu2, text="Accept\n", width=15, command=Interface.destroy)
- Accept.place(x=320, y=120)
- def CheckSum():
- global SumPeople
- try:
- if len(Ppl_Num_Input.get()) == 0:
- showinfo("System Info", "Warning: Please insert sommething")
- elif int(Ppl_Num_Input.get()) < 1:
- showinfo("System Info", "Warning: No negative number is allowed")
- else:
- print int(Ppl_Num_Input.get())
- PickingRestaurant()
- except ValueError:
- showinfo("System Info", "Warning: System detected you entered something strange!\nOnly integer is allowed!")
- def PrintRestInfoModule():
- Restaurant_Info = Toplevel()
- Restaurant_Info.title("Cyber Roll - Restaurant Info")
- Restaurant_Info.geometry("850x100")
- Restaurant_Info.resizable(0,0)
- Res_name = Label(Restaurant_Info, text="Restaurant Name : ")
- Res_name.place(x=20, y=20)
- Res_info = Label(Restaurant_Info, text=Selected)
- Res_info.place(x=160, y=20)
- Address = Label(Restaurant_Info, text="Restaurant Address : ")
- Address.place(x=20, y=50)
- Res_Address = Label(Restaurant_Info, text=SelectedRestaurantAddress)
- Res_Address.place(x=160, y=50)
- def ReRoll():
- try:
- SumPeople = int(SumPeople/2)
- VoteReRoll = int(Vote_Reroll.get())
- if len(Vote_Reroll.get()) == 0:
- showinfo("System Info", "Warning: The input is empty ! Please input something")
- elif int(Vote_Reroll.get()) <= 1:
- showinfo("System Info", "Warning: No negative number is allowed")
- elif (VoteReRoll>SumPeople):
- ReRoll.withdraw()
- PickingRestaurant()
- else:
- pass
- except ValueError:
- VoteReRoll =Vote_Reroll.get()
- SumPeople =Ppl_Num_Input.get()
- showinfo("System Info", "Warning: System detected you entered something strange!\nOnly integer is allowed!")
- def SignUpWindow():
- SignUp = Toplevel()
- SignUp.title("Cyber Roll")
- SignUp.geometry("450x200")
- SignUp.resizable(0,0)
- Greeting=Label(SignUp,text="Cyber Roll - Sign Up")
- Greeting.place(x=20,y=0)
- Reg_Username = Label(SignUp,text="Username: ")
- Reg_Username.place(x=20,y=40)
- global Reg_Username_Input
- Reg_Username_Input = Entry(SignUp,width=45)
- Reg_Username_Input.place(x=140,y=40)
- Reg_Password = Label(SignUp,text="Password: ")
- Reg_Password.place(x=20,y=70)
- global Reg_Password_Input
- Reg_Password_Input = Entry(SignUp,width=45,show="*")
- Reg_Password_Input.place(x=140,y=70)
- Reg_Passconfirm = Label(SignUp,text="Confirm Password: ")
- Reg_Passconfirm.place(x=20,y=100)
- global Reg_Passconfirm_Input
- Reg_Passconfirm_Input = Entry(SignUp,width=45,show="*")
- Reg_Passconfirm_Input.place(x=140,y=100)
- Sign_Up = Button(SignUp,width=15,text="Sign Up",command=Sign_Up_Module)
- Sign_Up.place(x=220,y=130)
- Homepage()
- Interface.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement