Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- import tkinter as tk
- from tkinter.messagebox import showinfo
- import tkinter.simpledialog
- import tkinter.messagebox
- class Game:
- def __init__(self, name, rating, price, publisher, sale):
- self.name = name
- self.rating = rating
- self.price = price
- self.publisher = publisher
- self.sale = sale #will be used a mutliplier e.g. 0.6 x price, 1 x price (default)
- gameList.append(self)
- class User:
- def __init__(self, username, password, balance, library):
- self.username = username
- self.password = password
- self.balance = balance
- self.library = library #this will be an array which will be added via, gta.name etc
- userList.append(self)
- class Buying():
- def __init__(self, *args): #REPEATED CODE IS NEEDED for some of the part,
- self.buywindow = Toplevel(root)
- self.buywindow.title("buy a game")
- self.buywindow.geometry('{}x{}'.format(500, 530))
- self.buywindow.resizable(0,0)
- self.buywindow.grab_set()#made it unclickable
- #########################
- labelCom = Label(self.buywindow, text="Purchase", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)
- labelgame = Label(self.buywindow, text="game avaliable", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
- labelCopies = Label(self.buywindow, text="how many copies", font=("arial", 18)).grid(row=2, column=0, sticky=N, padx=6, pady=6)
- ########################
- self.labelNoti = StringVar()
- self.labelNoti.set("asdf")
- self.labelNotiContent = Label(self.buywindow, textvariable=self.labelNoti, font=("arial", 8)).grid(row=3, column=0, sticky=N, padx=6, pady=6)
- ######################### dynamic label working :D ######################
- self.copiesEntry = StringVar()
- self.copiesEntry.trace("w", lambda name, index, mode, copiesEntry=self.copiesEntry: self.check_value(self.copiesEntry))
- self.copiesEntrytext = Entry(self.buywindow, textvariable=self.copiesEntry, state='normal')
- self.copiesEntrytext.grid(row=2, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
- ########################
- self.store_menu = StringVar()
- self.store_menu.set("this is your library")
- #self.store_menu("w", library)
- self.store_menu = OptionMenu(self.buywindow, self.testing, *gameList).grid(row=1, column=1, sticky=N, padx=6)
- def check_value(self, *args):
- inputedcopies = int(self.copiesEntrytext.get())
- print(inputedcopies)
- if inputedcopies <= 10:
- self.labelNoti.set("purchased")
- else:
- self.copiesEntry.set("")
- self.labelNoti.set("too many copies")
- #print("worked")
- def testing(self, *args):
- print("working")
- ################################################################################################################################################################################################
- class logining():
- def __init__(self, *args):
- self.loginwindow = Toplevel(root)
- self.loginwindow.title("Login")
- self.loginwindow.geometry('{}x{}'.format(400, 200))
- self.loginwindow.resizable(0,0)
- self.loginwindow.grab_set()#made it unclickable
- ############################################
- labelCom = Label(self.loginwindow, text="login", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)#login window is 1 frame
- labelCom = Label(self.loginwindow, text="username", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
- labelCom = Label(self.loginwindow, text="password", font=("arial", 18)).grid(row=2, column=0, sticky=N, padx=6, pady=6)
- ############################################
- self.usernameEntry = StringVar()
- self.usernameEntry.trace("w", lambda name, index, mode, usernameEntry=self.usernameEntry: self.test(self.usernameEntry))
- self.usernameEntrytext = Entry(self.loginwindow, textvariable="", state='normal')
- self.usernameEntrytext.grid(row=1, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
- ############################################
- self.passwordEntry = StringVar()
- self.passwordEntry.trace("w", lambda name, index, mode, passwordEntry=self.passwordEntry: self.test(self.passwordEntry))#make sure to add stake holder on the hide password
- self.passwordEntrytext = Entry(self.loginwindow, show="*", textvariable="", state='normal')#password thingy
- self.passwordEntrytext.grid(row=2, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
- ############################################
- #login button
- signinButton = Button(self.loginwindow, text="login", command=self.test, state="normal")#changing test() to test make it so that a button is needed,
- signinButton.grid(row=3, column=1)
- def test(self, *args): #*args is very important
- global sessionusername, sessionpassword, sessionlibrary, sessionbalance
- entereduser = str(self.usernameEntrytext.get())
- enteredpass = str(self.passwordEntrytext.get())
- print("####")
- print("")
- #print(self.usernameEntrytext.get(), self.passwordEntrytext.get())
- for users in userList:
- if entereduser == str(users.username) and enteredpass == str(users.password):
- sessionusername = entereduser
- sessionpassword = enteredpass
- sessionlibrary = users.library
- sessionbalance = users.balance
- print("current username: " +str(sessionusername), " current password: " +str(sessionpassword), "current library: " +str(sessionlibrary), "current balance:" +str(sessionbalance))
- #print("good")#signin working
- loginButton.config(state="disabled")
- logoutButton.config(state="normal")
- buyButton.config(state="normal")
- LabelbalanceTitle.set("your current balance is $" +str(sessionbalance)) #this one actually worked hmm
- library_menu.set(sessionlibrary)
- self.loginwindow.destroy()
- else:
- self.loginwindow.destroy()
- #print(sessionusername, sessionpassword)
- print("")
- print("####")
- #asdf = usernameEntrytext.get()
- #print(asdf)
- #if username1 == username and password1 == password:
- # print("it worked")
- #else:
- # print("failed")
- #
- ################################################################################################################################################################################################
- def logoutfunc(*args):
- global sessionusername, sessionpassword, sessionlibrary, sessionbalance
- sessionusername = ""
- sessionpassword = ""
- sessionlibrary = []
- sessionbalance = ""
- loginButton.config(state="normal")
- logoutButton.config(state="disabled") #after loging out it should pretty much reset everything that means clearing everything
- print("current username: " +str(sessionusername), " current username: " +str(sessionpassword), "current library: " +str(sessionlibrary), "current balance:" +str(sessionbalance))
- def salesfunc(*args):
- saleswindow = Toplevel(root)
- saleswindow.title("Sales!")
- saleswindow.geometry('{}x{}'.format(400, 300))
- saleswindow.resizable(0,0)
- saleswindow.grab_set()#made it unclickable
- def usersetfunc(*args):
- usersetwindow = Toplevel(root)
- usersetwindow.title("User Setting")
- usersetwindow.geometry('{}x{}'.format(400, 300))
- usersetwindow.resizable(0,0)
- usersetwindow.grab_set()#made it unclickable
- def library(*args):
- library_menu.set(sessionlibrary)
- #interface code it's pretty aesthetic i know
- root = Tk()
- root.title('Steam Backup Launcher')
- root.resizable(0,0)
- root.geometry('{}x{}'.format(430, 375))
- root.configure(background="black")
- mainFrame = Frame(root)
- BotFrame = Frame(root)
- #all these arrays are for filters uwu
- gameNames = []
- gameList = []
- userList = []
- userName = []
- userPass = []
- GTA4 = Game("grand theft auto 4", "3/5", 45, "rockstar", 1) #name, stock, price, publisher
- destiny = Game("destiny", "4/5", 45, "bungie", 1) #name, stock, price, publisher
- overwatch = Game("overwatch", "4/5", 60, "blizzard", 1) #name, stock, price, publisher
- jamie = User("joji", "2low4ahoe", 0, [GTA4.name, destiny.name, overwatch.name])#game library working! #make a loop that runs througha list
- ray = User("test", "test", 244, [GTA4.name, overwatch.name])
- #globals
- sessionusername = ""
- sessionpassword = ""
- sessionlibrary = [""]
- sessionbalance = 0
- currentlibrary = ['gta','overwatch','destiny']
- print(GTA4.name + GTA4.rating)
- print(jamie.username + " " + str(jamie.library))
- #title
- labelCom = Label(mainFrame, text="steam", font=("arial", 34), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)
- #buy pop up box i want to make a list of avaliable game where they can be displayed
- buyButton = Button(mainFrame, text="Buy", state='normal', command=lambda: Buying())
- buyButton.grid(row=1, column=0, ipadx=10, ipady=5, padx=10)
- #login button
- loginButton = Button(mainFrame, text="Login", command=lambda: logining())
- loginButton.grid(row=1, column=2, ipadx=10, ipady=5, padx=10)
- #logout pop up box i want to make a list of avaliable game where they can be displayed
- logoutButton = Button(BotFrame, text="Logout", state='disabled', command=lambda: logoutfunc())
- logoutButton.grid(row=3, column=2, ipadx=10, ipady=5, padx=10)
- #sales pop up box i want to make a list of games of sale
- salesButton = Button(BotFrame, text="Sales!", state='disabled', command=salesfunc)
- salesButton.grid(row=3, column=0, ipadx=10, ipady=5, padx=10)
- #settings pop up box i want to make a list of games of sale
- usersetButton = Button(BotFrame, text="user setting", state='disabled', command=usersetfunc)
- usersetButton.grid(row=2, column=1, ipadx=10, ipady=5, padx=10)
- #library
- library_menu = StringVar()
- library_menu.set("this is your library")
- #library_menu("w", library)
- library_menu_Content = OptionMenu(mainFrame, logoutfunc, *currentlibrary).grid(row=2, column=1, sticky=N, padx=6) #run a funciton in login that sets jamie.library to different users
- # i just need to make a button to send it info in since it activates the funciton when a new product is selected (sell button)
- #balance display
- LabelbalanceTitle = StringVar()
- LabelbalanceTitle.set("your current balance is $")
- LabelbalanceTitleContent = Label(BotFrame, textvariable=LabelbalanceTitle, font=("arial", 9), background="#999", width=30).grid(row=3, column=1, sticky=N, padx=20, pady=3)
- #main frame
- mainFrame.pack(side=TOP, fill=BOTH, expand=TRUE)
- BotFrame.pack(side=BOTTOM, fill=BOTH, expand=TRUE)
- root.mainloop()
- #all prints are for testing purposes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement