Guest User

Untitled

a guest
Nov 9th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.05 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3. import tkinter as tk
  4. from tkinter.messagebox import showinfo
  5. import tkinter.simpledialog
  6. import tkinter.messagebox
  7. import datetime
  8.  
  9. ################################################################################################################################################################################################
  10.  
  11. class Game:
  12. def __init__(self, name, rating, price, publisher, sales):
  13. self.name = name
  14. self.rating = rating
  15. self.price = price
  16. self.publisher = publisher
  17. self.sales = sales
  18. gameName.append(self)
  19. gameList.append(self.name)
  20. gamePrice.append(self.price)
  21. gameSales.append(self.sales)
  22.  
  23. ################################################################################################################################################################################################
  24.  
  25. class User:
  26. def __init__(self, username, password, balance, credit, EXPD, CVC, library):
  27. self.username = username
  28. self.password = password
  29. self.balance = balance
  30. self.credit = credit
  31. self.EXPD = EXPD
  32. self.CVC = CVC
  33. self.library = library #this will be an array which will be added via, gta.name etc
  34. userList.append(self)
  35. userLib.append(self.library)
  36.  
  37.  
  38. ################################################################################################################################################################################################
  39.  
  40. class Buying():
  41.  
  42. global selectedgame, sessionlibrary, sessionbalance, cart, checkout_price
  43. def __init__(self, *args): #REPEATED CODE IS NEEDED for some of the part,
  44. self.buywindow = Toplevel(root)
  45. self.buywindow.title("buy a game")
  46. self.buywindow.geometry('{}x{}'.format(510, 300))
  47. self.buywindow.resizable(0,0)
  48. self.buywindow.grab_set()#made it unclickable
  49. #########################
  50. labelCom = Label(self.buywindow, text="Purchase", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)
  51. labelgame = Label(self.buywindow, text="game avaliable", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
  52. #labelCopies = Label(self.buywindow, text="how many copies", font=("arial", 18)).grid(row=2, column=0, sticky=N, padx=6, pady=6)
  53. ########################
  54. self.labelCartlist = StringVar()
  55. self.labelCartlist.set("cart list:")
  56. self.labelCartContent = Label(self.buywindow, textvariable=self.labelCartlist, font=("arial 10 bold")).grid(row=4, column=0, sticky=N, padx=6, pady=6)
  57. ########################
  58. labelremove = Label(self.buywindow, text="to remove from your cart", font=("arial 10 bold")).grid(row=4, column=1, sticky=N, padx=6, pady=6)
  59. ########################
  60. self.removeEntry = StringVar()
  61. self.removeEntry.trace("w", lambda name, index, mode, removeEntry=self.removeEntry: self.delete(self.removeEntry))
  62. self.removeEntrytext = Entry(self.buywindow, textvariable="", state='disabled')
  63. self.removeEntrytext.grid(row=5, column=1, padx=6, pady=6, ipadx=10, ipady=8)
  64. ########################
  65. self.removedbutton = Button(self.buywindow, text="remove from cart", command=self.delete, state="disabled")#changing test() to test make it so that a button is needed,
  66. self.removedbutton.grid(row=5, column=2)
  67. ########################
  68. self.labelCart = StringVar() ###### tempcart thingy
  69. self.labelCart.set("")
  70. self.labelCartContent = Label(self.buywindow, textvariable=self.labelCart, font=("arial", 10)).grid(row=5, column=0, sticky=N, padx=6, pady=6)
  71. ########################
  72. self.labelNoti = StringVar()
  73. self.labelNoti.set("")
  74. self.labelNotiContent = Label(self.buywindow, textvariable=self.labelNoti, font=("arial", 8)).grid(row=3, column=0, sticky=N, padx=6, pady=6)
  75. ########################
  76. self.labelPrice = StringVar()
  77. self.labelPrice.set("$0")
  78. self.labelPriceContent = Label(self.buywindow, textvariable=self.labelPrice, font=("arial", 14)).grid(row=1, column=2, sticky=N, padx=6, pady=6)
  79. ######################### dynamic label working :D ######################
  80. self.store_menu = StringVar()
  81. self.store_menu.set("please select a game")
  82. self.store_menu.trace("w", self.select_game)
  83. self.store_menuoption = OptionMenu(self.buywindow, self.store_menu, command=self.update, *gameList).grid(row=1, column=1, sticky=N, padx=6, rowspan=1)
  84. ########################
  85. self.loading = Button(self.buywindow, text="add to cart", command=self.purchasing, state="disabled")#changing test() to test make it so that a button is needed,
  86. self.loading.grid(row=3, column=1)
  87. #############buying process
  88. self.buy = Button(self.buywindow, text="checkout!", command=self.checkout, state="disabled")#changing test() to test make it so that a button is needed,
  89. self.buy.grid(row=3, column=2)
  90.  
  91. def update(self, *args): #price update
  92. for selling_price in gameName:
  93. if selectedgame == selling_price.name:
  94. print("game name:",selectedgame, "game price:",selling_price.price)
  95. post = "$" +str(selling_price.price)
  96. self.labelPrice.set(post)
  97.  
  98. def delete(self, *args): #work on this make it so that they remove an item
  99. global cart, checkout_price
  100. print("")
  101. print("first cart: ", cart)
  102. removing_item = str(self.removeEntrytext.get())
  103. print("removing_game: ", removing_item)
  104. print("")
  105. for x in range(0, len(cart)):
  106. if removing_item in cart: #don't put it as cart[x] ever again >:C
  107. if removing_item == cart[x]: #i did it
  108. del cart[int(x)] #del that item in the array
  109. print("new cart: ", cart)
  110. self.labelNoti.set("item removed")
  111. for selling_price in gameName: #refunding the price owo
  112. if removing_item == selling_price.name: #checking if the removes work
  113. print("2 game name:",removing_item, ", 2 game price: $",selling_price.price)
  114. checkout_price -= int(selling_price.price)
  115. print(checkout_price)
  116. else:
  117. self.labelNoti.set("item not found or has been removed")
  118. ###########################################################
  119. #resetting the text box and the button
  120. #find a way to refersh the tempcart or display cart
  121. ###########################################################
  122. tempcart = ""
  123. for i in range(0, len(cart)): #temp cart is just cart display
  124. tempcart += str(cart[i]) + "\n"
  125. self.labelCart.set(tempcart)#notifications to show what the user have probably should make a remove cart :/
  126. i += 1
  127. self.removeEntrytext.delete(0, 'end')
  128. if len(cart) == 0:
  129. self.removeEntrytext.config(state='disabled')
  130. self.removedbutton.config(state="disabled")
  131. print("new checkout price",checkout_price)
  132. self.labelCart.set("")
  133. else:
  134. pass
  135. print("new checkout price",checkout_price)
  136.  
  137. def purchasing(self, *args):
  138. global sessionlibrary, selectedgame, sessionbalance, cart, checkout_price, tempcart
  139. tempcart = ""
  140. print(selectedgame)
  141. print("old sesh ", sessionlibrary)
  142. print("selectedgame: ", selectedgame)
  143. if str(selectedgame) not in sessionlibrary and str(selectedgame) not in cart: #if it's not in cart or library
  144. for selling_price in gameName:
  145. if selectedgame == selling_price.name:
  146. print("2 game name:",selectedgame, ", 2 game price: $",selling_price.price)
  147. checkout_price += int(selling_price.price)
  148. print("old checkout_price: ",checkout_price) #adding the prices to the checkout price which will remove from the sessionbalance
  149. cart += str(selectedgame).strip().split(',')#adds in stuff
  150. print("cart ", cart)
  151. print("sessionlibrary: ", sessionlibrary)
  152. self.store_menu.set("please select a game")
  153. self.labelNoti.set("added to cart!")
  154. for i in range(0, len(cart)): #temp cart is just cart display
  155. tempcart += str(cart[i]) + "\n"
  156. self.labelCart.set(tempcart)#notifications to show what the user have probably should make a remove cart :/
  157. i += 1
  158. self.loading.config(state='disabled')
  159. self.buy.config(state='normal')
  160. selectedgame = "" #resetting selected game
  161. self.removeEntrytext.config(state='normal')
  162. self.removedbutton.config(state="normal") #setting it so you can remove from the cart
  163. else:
  164. self.store_menu.set("please select a game")
  165. self.labelNoti.set("you've already bourght \n that game or it's in your\ncart")
  166. self.loading.config(state='disabled')
  167. pass
  168.  
  169. def checkout(self, *args):
  170. global sessionlibrary, cart, selectedgame, sessionbalance, checkout_price
  171. if sessionbalance <= 0:
  172. self.labelNoti.set("you're broke get \nsome money")
  173. elif len(cart) <= 0:
  174. self.labelNoti.set("nothing to check \nout")
  175. else:
  176. print("cart items: ", cart[0])
  177. #adding the game to the new library
  178. for i in range(0, len(cart)):
  179. sessionlibrary += str(cart[i]).strip().split(',')
  180. print("new sessionlibrary: ", sessionlibrary)
  181. i += 1
  182. cart = []#resstting cart
  183. self.labelCart.set("")
  184. selectedgame = ""
  185. self.buy.config(state='disabled')
  186. self.labelPrice.set("$0")
  187. sessionbalance -= checkout_price
  188. #print(sessionbalance) testting to see if it even gets through
  189. LabelbalanceTitle.set("your current balance is $" +str(sessionbalance))
  190. checkout_price = 0 #ressetting checkout price for the next round :D
  191. self.removeEntrytext.config(state='disabled')
  192. self.removedbutton.config(state="disabled") #setting it so you can remove from the cart
  193.  
  194. def select_game(self, *args):
  195. global sessionlibrary, selectedgame
  196. selectedgame = str(self.store_menu.get())
  197. print(selectedgame)
  198. print(sessionlibrary)
  199. self.store_menu.set(selectedgame)
  200. self.loading.config(state='normal')
  201.  
  202. ################################################################################################################################################################################################
  203.  
  204. class logining():
  205. def __init__(self, *args):
  206. self.loginwindow = Toplevel(root)
  207. self.loginwindow.title("Login")
  208. self.loginwindow.geometry('{}x{}'.format(400, 200))
  209. self.loginwindow.resizable(0,0)
  210. self.loginwindow.grab_set()#made it unclickable
  211. ############################################
  212. 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
  213. labelCom = Label(self.loginwindow, text="username", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
  214. labelCom = Label(self.loginwindow, text="password", font=("arial", 18)).grid(row=2, column=0, sticky=N, padx=6, pady=6)
  215. ############################################
  216. self.usernameEntry = StringVar()
  217. self.usernameEntry.trace("w", lambda name, index, mode, usernameEntry=self.usernameEntry: self.test(self.usernameEntry))
  218. self.usernameEntrytext = Entry(self.loginwindow, textvariable="", state='normal')
  219. self.usernameEntrytext.grid(row=1, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  220. ############################################
  221. self.passwordEntry = StringVar()
  222. 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
  223. self.passwordEntrytext = Entry(self.loginwindow, show="*", textvariable="", state='normal')#password thingy
  224. self.passwordEntrytext.grid(row=2, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  225. ############################################
  226. #login button
  227. signinButton = Button(self.loginwindow, text="login", command=self.test, state="normal")#changing test() to test make it so that a button is needed,
  228. signinButton.grid(row=3, column=1)
  229. def test(self, *args): #*args is very important
  230. global sessionusername, sessionpassword, sessionlibrary, sessionbalance, sessioncredit, sessionEXPD, sessionCVC
  231. entereduser = str(self.usernameEntrytext.get())
  232. enteredpass = str(self.passwordEntrytext.get())
  233. print("####")
  234. print("")
  235. for users in userList:
  236. if entereduser == str(users.username) and enteredpass == str(users.password):
  237. sessionusername = entereduser
  238. sessionpassword = enteredpass
  239. sessionlibrary = users.library
  240. sessionbalance = users.balance
  241. sessioncredit = users.credit
  242. sessionEXPD = users.EXPD
  243. sessionCVC = users.CVC
  244. ##################################
  245. print("current username: " +str(sessionusername), " current password: " +str(sessionpassword), "current library: " +str(sessionlibrary), "current balance:" +str(sessionbalance))
  246. loginButton.config(state="disabled")
  247. logoutButton.config(state="normal")
  248. buyButton.config(state="normal")
  249. salesButton.config(state="normal")
  250. libraryButton.config(state="normal")
  251. usersetButton.config(state="normal")
  252. LabelbalanceTitle.set("your current balance is $" +str(sessionbalance)) #this one actually worked hmm\
  253. LabelusernameTitle.set("Username: \n"+str(sessionusername))
  254. self.loginwindow.destroy()
  255. else:
  256. self.loginwindow.destroy()
  257. print("")
  258. print("####")
  259.  
  260. def logoutfunc(*args):
  261. global sessionusername, sessionpassword, sessionlibrary, sessionbalance
  262. sessionusername = ""
  263. sessionpassword = ""
  264. sessionlibrary = []
  265. sessionbalance = 0
  266. LabelbalanceTitle.set("your current balance is $" +str(sessionbalance))
  267. buyButton.config(state="disabled")
  268. salesButton.config(state="disabled")
  269. libraryButton.config(state="disabled")
  270. usersetButton.config(state="disabled")
  271. loginButton.config(state="normal")
  272. logoutButton.config(state="disabled") #after loging out it should pretty much reset everything that means clearing everything
  273. print("current username: " +str(sessionusername), " current username: " +str(sessionpassword), "current library: " +str(sessionlibrary), "current balance:" +str(sessionbalance))
  274.  
  275. ################################################################################################################################################################################################
  276.  
  277. class salesfunc(): #gotta finish this for the last day yaayyyyyy
  278. global selectedgame, sessionlibrary, sessionbalance, cart
  279. tempsales = ""
  280. def __init__(self, *args): #REPEATED CODE IS NEEDED for some of the part,
  281. self.saleswindow = Toplevel(root)
  282. self.saleswindow.title("Sales!")
  283. self.saleswindow.geometry('{}x{}'.format(700, 300))
  284. self.saleswindow.resizable(0,0)
  285. self.saleswindow.grab_set()#made it unclickable
  286. #########################
  287. labelCom = Label(self.saleswindow, text="SALES!", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)
  288. labelgame = Label(self.saleswindow, text="game avaliable", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
  289. #########################
  290. self.labelsales = StringVar()
  291. self.labelsales.set("games on sale")
  292. self.labelsalesContent = Label(self.saleswindow, textvariable=self.labelsales, font=("arial", 16)).grid(row=2, column=1, sticky=N, padx=6, pady=6)
  293. #########################
  294. self.buy = Button(self.saleswindow, text="buy a game!", command=lambda: Buying(), state="normal")#changing test() to test make it so that a button is needed,
  295. self.buy.grid(row=1, column=1, ipadx=40, ipady=5)
  296.  
  297. for selling_price in gameName:
  298. if gameSales == selling_price.sales:
  299. print("gameSales :",gameSales, "selling_prices:",selling_price.sales)
  300. self.labelsales.set("")
  301.  
  302. ################################################################################################################################################################################################
  303.  
  304. class usersetfunc():
  305. def __init__(self, *args):
  306. self.usersetwindow = Toplevel(root)
  307. self.usersetwindow.title("User Setting")
  308. self.usersetwindow.geometry('{}x{}'.format(500, 400))
  309. self.usersetwindow.resizable(0,0)
  310. self.usersetwindow.grab_set()#made it unclickable
  311. ########################
  312. labelUSET = Label(self.usersetwindow, text="User Settings", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)#login window is 1 frame
  313. labelUSER = Label(self.usersetwindow, text="username", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
  314. labelPASS = Label(self.usersetwindow, text="password", font=("arial", 18)).grid(row=2, column=0, sticky=N, padx=6, pady=6)
  315. labelCOMF = Label(self.usersetwindow, text="password confirm", font=("arial", 18)).grid(row=3, column=0, sticky=N, padx=6, pady=6)
  316. labelCCNO = Label(self.usersetwindow, text="credit card number", font=("arial", 18)).grid(row=4, column=0, sticky=N, padx=6, pady=6)
  317. labelEXPD = Label(self.usersetwindow, text="expiry date", font=("arial", 18)).grid(row=5, column=0, sticky=N, padx=6, pady=6)
  318. labelCVVC = Label(self.usersetwindow, text="CVV number", font=("arial", 18)).grid(row=6, column=0, sticky=N, padx=6, pady=6)
  319. ############################################label USER
  320. self.USER = StringVar()
  321. self.USER.trace("w", lambda name, index, mode, USER=self.USER: self.updatefunc(self.USER))
  322. self.USERtext = Entry(self.usersetwindow, textvariable="", state='normal')
  323. self.USERtext.grid(row=1, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  324. ############################################label PASS
  325. self.PASS = StringVar()
  326. self.PASS.trace("w", lambda name, index, mode, PASS=self.PASS: self.updatefunc(self.PASS))
  327. self.PASStext = Entry(self.usersetwindow, textvariable="", state='normal')
  328. self.PASStext.grid(row=2, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  329. ############################################label COMF
  330. self.COMF = StringVar()
  331. self.COMF.trace("w", lambda name, index, mode, COMF=self.COMF: self.updatefunc(self.COMF))
  332. self.COMFtext = Entry(self.usersetwindow, textvariable="", state='normal')
  333. self.COMFtext.grid(row=3, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  334. ############################################label CCNO
  335. self.CCNO = StringVar()
  336. self.CCNO.trace("w", lambda name, index, mode, CCNO=self.CCNO: self.updatefunc(self.CCNO))
  337. self.CCNOtext = Entry(self.usersetwindow, textvariable="", state='normal')
  338. self.CCNOtext.grid(row=4, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  339. ############################################label EXPD
  340. self.EXPD = StringVar()
  341. self.EXPD.trace("w", lambda name, index, mode, EXPD=self.EXPD: self.updatefunc(self.EXPD))
  342. self.EXPDtext = Entry(self.usersetwindow, textvariable="", state='normal')
  343. self.EXPDtext.grid(row=5, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  344. ############################################label CVVC
  345. self.CVVC = StringVar()
  346. self.CVVC.trace("w", lambda name, index, mode, CVVC=self.CVVC: self.updatefunc(self.CVVC))
  347. self.CVVCtext = Entry(self.usersetwindow, textvariable="", state='normal')
  348. self.CVVCtext.grid(row=6, column=1, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  349. ############################################
  350. self.changeButton = Button(self.usersetwindow, text="update", command=self.updatefunc, state="normal")#changing test() to test make it so that a button is needed,
  351. self.changeButton.grid(row=7, column=1, ipadx=40, ipady=5)
  352. ############################################
  353. self.labelNoti = StringVar()
  354. self.labelNoti.set("")
  355. self.labelNotiContent = Label(self.usersetwindow, textvariable=self.labelNoti, font=("arial", 10)).grid(row=7, column=0, sticky=N, padx=6, pady=6)
  356.  
  357. def updatefunc(self, *args):
  358. global sessionusername, sessionpassword, sessioncredit, sessionEXPD, sessionCVC
  359. updating_USER = str(self.USERtext.get())
  360. updating_PASS = str(self.PASStext.get())
  361. updating_COMF = str(self.COMFtext.get())
  362. updating_CCNO = str(self.CCNOtext.get()) #got a credit card system working today finally didn't took as long as i thought it would which is nice
  363. updating_EXPD = str(self.EXPDtext.get())
  364. updating_CVVC = str(self.CVVCtext.get())
  365. if updating_USER == "":
  366. self.labelNoti.set("make sure to fill \nin the blank")
  367. elif updating_PASS == "":
  368. self.labelNoti.set("make sure to fill \nin the blank")
  369. elif updating_COMF == "":
  370. self.labelNoti.set("make sure to fill \nin the blank")
  371. elif updating_CCNO == "":
  372. self.labelNoti.set("make sure to fill \nin the blank")
  373. elif updating_EXPD == "":
  374. self.labelNoti.set("make sure to fill \nin the blank")
  375. elif updating_CVVC == "":
  376. self.labelNoti.set("make sure to fill \nin the blank")
  377. elif updating_CCNO.isnumeric() == False or updating_CVVC.isnumeric() == False:
  378. self.labelNoti.set("please make sure you\n the correct credit card info")
  379. elif len(updating_CCNO) < 15 or len(updating_CCNO) > 19: #credit card number ranges from 15 to 19
  380. self.labelNoti.set("make sure to fill \nin 19 digits of the card")
  381. elif len(updating_CVVC) != 3:#more effective than > 3 or < 3 since there can only be 3 digits
  382. self.labelNoti.set("make sure to fill \nin 3 digits of the CVV")
  383. elif len(updating_EXPD) != 4:#more effective than > 4 or < 4 since there can only be 3 digits
  384. self.labelNoti.set("make sure to fill \nin 4 digits of the date \ne.g. 0319 = march-19")
  385. elif updating_COMF != updating_PASS:
  386. self.labelNoti.set("passwords do not \nmatch")
  387. else: #all fool proofing it before updating it :D
  388. sessionusername = updating_USER
  389. sessionpassword = updating_PASS
  390. sessioncredit = updating_CCNO #session and library are missing as it's just the same user updating is information
  391. sessionEXPD = updating_EXPD
  392. sessionCVC = updating_CVVC
  393. self.labelNoti.set("update complete!")
  394. LabelusernameTitle.set("Username: \n"+str(sessionusername))
  395. print("sessionusername",sessionusername,"sessionpassword",sessionpassword,"sessioncredit",sessioncredit,"sessionEXPD",sessionEXPD,"sessionCVC",sessionCVC)
  396.  
  397. ################################################################################################################################################################################################
  398.  
  399. class library():
  400. def __init__(self, *args):
  401. global sessionlibrary
  402. templibrary = "" #making it [] would mess up formatting
  403. self.librarywindow = Toplevel(root)
  404. self.librarywindow.title("User Setting")
  405. self.librarywindow.geometry('{}x{}'.format(500, 300))
  406. self.librarywindow.resizable(0,0)
  407. self.librarywindow.grab_set()#made it unclickable
  408. #################################################
  409. labelTitle = Label(self.librarywindow, text="Library", font=("arial", 24), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)#login window is 1 frame
  410. labelUSER = Label(self.librarywindow, text="Games you own: ", font=("arial", 18)).grid(row=1, column=0, sticky=N, padx=6, pady=6)
  411. #################################################
  412. self.labelLibrarylist = StringVar()
  413. self.labelLibrarylist.set("")
  414. self.labelLibrarylistContent = Label(self.librarywindow, textvariable=self.labelLibrarylist, font=("arial", 16)).grid(row=1, column=1, sticky=N, padx=6, pady=6)
  415. ############################################
  416. self.gaming = StringVar()
  417. self.gaming.trace("w", lambda name, index, mode, gaming=self.gaming: self.passing(self.gaming))
  418. self.gamingtext = Entry(self.librarywindow, textvariable=self.gaming, state='normal')
  419. self.gamingtext.grid(row=2, column=0, padx=6, pady=6, ipadx=15, ipady=8, rowspan=1, sticky="ew")
  420. ############################################
  421. self.changeButton = Button(self.librarywindow, text="launch a game", command=self.gamelauncher, state="normal")#changing test() to test make it so that a button is needed,
  422. self.changeButton.grid(row=2, column=1, ipadx=40, ipady=5)
  423. #################################################
  424. self.labelNoti = StringVar()
  425. self.labelNoti.set("")
  426. self.labelNotiContent = Label(self.librarywindow, textvariable=self.labelNoti, font=("arial", 10)).grid(row=7, column=0, sticky=N, padx=6, pady=6)
  427. ################################################# pre loading'''
  428. for i in range(0, len(sessionlibrary)): #working
  429. templibrary += str(sessionlibrary[i]) + "\n"
  430. self.labelLibrarylist.set(templibrary)#display all games in the library
  431. i += 1
  432.  
  433. def gamelauncher(self, *args):
  434. global sessionlibrary
  435. print(sessionlibrary)
  436. game = self.gaming.get()
  437. print("game selected:"+str(game), " |")
  438. if game not in sessionlibrary:
  439. self.labelNoti.set("you don't own \nthat game")
  440. else:
  441. self.gamingtext.delete(0, 'end')
  442. self.changeButton.config(state='disabled')
  443. self.gamingtext.config(state="disabled") #setting it so you can remove from the cart
  444.  
  445.  
  446. ################################################################################################################################################################################################
  447.  
  448. #interface code it's pretty aesthetic i know
  449. root = Tk()
  450. root.title('Steam Backup Launcher')
  451. root.resizable(0,0)
  452. root.geometry('{}x{}'.format(600, 400))
  453. root.configure(background="black")
  454. mainFrame = Frame(root)
  455. BotFrame = Frame(root)
  456.  
  457. #all these arrays are for filters uwu
  458. gameName = []
  459. gameList = []
  460. userList = []
  461. userName = []
  462. userPass = []
  463. userLib = []
  464. gameSales = []
  465. gamePrice = []
  466. cart = []
  467. tempcart = []
  468.  
  469. GTA4 = Game("Grand Theft Auto 4", "3/5", 45, "rockstar", False) #name, stock, price, publisher
  470. destiny = Game("Destiny", "4/5", 75, "bungie", True) #name, stock, price, publisher
  471. overwatch = Game("Overwatch", "4/5", 20, "blizzard", False) #name, stock, price, publisher
  472. red_dead_2 = Game("Red Dead Redemption", "4/5", 90, "rockstar", False) #name, stock, price, publisher
  473. LOL = Game("League of Legends", "4/5", 10, "riot games", False) #name, stock, price, publisher
  474.  
  475. jamie = User("t", "t", 0, 4536955883665515, 1232, 121, [GTA4.name, destiny.name, overwatch.name])#game library working! #make a loop that runs througha list
  476. ray = User("test", "test", 244, 4924087596280182, 1222, 431, [GTA4.name, overwatch.name])
  477.  
  478. #globals
  479. sessionusername = ""
  480. sessionpassword = ""
  481. sessioncredit = ""
  482. sessionEXPD = ""
  483. sessionCVC = ""
  484. sessionlibrary = []
  485. sessionbalance = 0
  486. checkout_price = 0
  487. selectedgame = ''#needed it for buying class
  488.  
  489. #currentlibrary = ['gta','overwatch','destiny']
  490.  
  491. #print(GTA4.name + GTA4.rating)
  492. #print(jamie.username + " " + str(jamie.library))
  493.  
  494. #title
  495. labelCom = Label(mainFrame, text="steam", font=("arial", 34), background="#999", width=10).grid(row=0, column=1, sticky=N, padx=6, pady=6)
  496.  
  497. #buy pop up box i want to make a list of avaliable game where they can be displayed
  498. buyButton = Button(mainFrame, text="Buy", state='disabled', command=lambda: Buying())
  499. buyButton.grid(row=1, column=0, ipadx=60, ipady=30, sticky=NSEW)
  500.  
  501. #login button
  502. loginButton = Button(mainFrame, text="Login", command=lambda: logining())
  503. loginButton.grid(row=1, column=2, ipadx=60, ipady=30, sticky=NSEW)
  504.  
  505. #logout pop up box i want to make a list of avaliable game where they can be displayed
  506. logoutButton = Button(BotFrame, text="Logout", state='disabled', command=root.destroy)
  507. logoutButton.grid(row=3, column=2, ipadx=60, ipady=30, sticky=NSEW)
  508.  
  509. #sales pop up box i want to make a list of games of sale
  510. salesButton = Button(BotFrame, text="Sales!", state='disabled', command=lambda: salesfunc())
  511. salesButton.grid(row=3, column=0, ipadx=60, ipady=30, sticky=NSEW)
  512.  
  513. #settings pop up box i want to make a list of games of sale
  514. usersetButton = Button(BotFrame, text="user setting", state='disabled', command=usersetfunc)
  515. usersetButton.grid(row=3, column=1, ipadx=70, ipady=30, sticky=NSEW)
  516.  
  517. #library
  518. libraryButton = Button(mainFrame, text="library", state='disabled', command=library, width=10)#run a funciton in login that sets jamie.library to different users
  519. libraryButton.grid(row=1, column=1, ipadx=70, ipady=30, sticky=NSEW)
  520. # 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)
  521.  
  522. #balance display
  523. LabelbalanceTitle = StringVar()
  524. LabelbalanceTitle.set("your current balance is $")
  525. LabelbalanceTitleContent = Label(BotFrame, textvariable=LabelbalanceTitle, font=("arial", 9), background="#999", width=30).grid(row=2, column=1, sticky=NSEW, padx=20, pady=3)
  526.  
  527. #balance display
  528. LabelusernameTitle = StringVar()
  529. LabelusernameTitle.set("Username: ")
  530. LabelusernameTitleContent = Label(mainFrame, textvariable=LabelusernameTitle, font=("arial", 12), background="#999").grid(row=0, column=2)
  531.  
  532. #main frame
  533. mainFrame.pack(side=TOP, fill=BOTH, expand=TRUE)
  534. BotFrame.pack(side=BOTTOM, fill=BOTH, expand=TRUE)
  535.  
  536. root.mainloop()
  537. #all prints are for testing purposes
Add Comment
Please, Sign In to add comment