-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdd
180 lines (148 loc) · 6.72 KB
/
Add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
from tkinter import *
import tkinter.messagebox as tm
import tkinter as tk
import Users
import re
from tkinter import ttk
import sqlite3
from Popup import *
db = sqlite3.connect('game nebula.db')
c = db.cursor()
genres= ['Action Role-Playing', 'Action-Adventure', 'Fighting', \
'Party Game', 'Platformer', 'Racing', 'Real-Time Strategy', 'Rhythm Game', 'Role-Playing', 'Sandbox', 'Shooter','Survival Horror', ]
publishers= ['Other', 'Warner Brothers', 'Valve Corporation', 'Ubisoft', 'Square Enix', 'Sony Computer Entertainment', 'Sega', 'SUPERHOT Team', 'Nintendo', 'Microsoft Studios', \
'Konami', 'Harmonix', 'Frictional Games', 'Electronic Arts', 'Digital Extremes', 'Deep Silver', 'Capcom', 'Bethesda Softworks', \
'Bandai Namco Entertainment', 'Activision', '343 Industries', '2K Games']
publishers.reverse()
class AddFrame(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.master = master
self.mainUI()
def mainUI(self):
self.master.title("Games Nebula")
self.pack(fill=BOTH, expand=True)
root.resizable(width=FALSE, height=FALSE)
frame1 = Frame(self)
frame1.pack(fill=X)
frame2 = Frame(self)
frame2.pack(fill=X)
frame3 = Frame(self)
frame3.pack(fill=X)
frame4 = Frame(self)
frame4.pack(fill=X)
frame5 = Frame(self)
frame5.pack(fill=X)
frame6 = Frame(self, padx=30)
frame6.pack(fill=X)
self.add_label = Label(frame1, text="Add a Game", fg='green', relief='groove', width='80')
self.add_label.pack(side=TOP, padx=5, pady=5)
self.game_label = Label(frame2, text="Game name")
self.game_label.pack(side=LEFT, padx=5, pady=5)
self.game_entry = Entry(frame2, borderwidth=2)
self.game_entry.pack(side=LEFT)
self.genre_label = Label(frame2, text="Genre")
self.genre_label.pack(side=LEFT, padx=5, pady=5)
self.genreBoxvalue = StringVar(root)
self.genreBox = ttk.Combobox(frame2, textvariable=self.genreBoxvalue)
self.genreBox['values'] = (genres)
self.genreBox.current(0)
self.genreBox.pack(side=LEFT, padx=5)
self.rating_label = Label(frame2, text="Rating")
self.rating_label.pack(side=LEFT, padx=1, pady=5)
self.ratingBoxvalue = StringVar(root)
self.ratingBox = ttk.Combobox(frame2, textvariable=self.ratingBoxvalue)
self.ratingBox['values']= ('Everyone', 'Teen', 'Mature')
self.ratingBox.current(2)
self.ratingBox.pack(side=LEFT, padx=5)
self.publisher_label = Label(frame3, text="Publisher")
self.publisher_label.pack(side=LEFT, padx=5, pady=5)
self.publisherBoxvalue = StringVar(root)
self.publisherBox = ttk.Combobox(frame3, textvariable=self.publisherBoxvalue)
self.publisherBox['values'] = (publishers)
self.publisherBox.current(0)
self.publisherBox.pack(side=LEFT, padx=5, pady=20)
self.release_label = Label(frame3, text="Release Date (mm/dd/yyyy)")
self.release_label.pack(side=LEFT, padx=20, pady=5)
self.release_entry = Entry(frame3, borderwidth=2)
self.release_entry.pack(side=LEFT)
self.mode_label = Label(frame4, text="Multi-Player?", relief = 'groove')
self.mode_label.pack(side=LEFT, padx=5, pady=5)
self.mpSpinBox = Spinbox(frame4, values=('Yes', 'No'), width=8)
self.mpSpinBox.pack(side=LEFT, pady=10)
self.mode_label = Label(frame4, text="Single Player?", relief='groove')
self.mode_label.pack(side=LEFT, padx=5, pady=5)
self.spSpinBox = Spinbox(frame4, values = ('Yes', 'No'), width=8)
self.spSpinBox.pack(side=LEFT, pady=10)
self.mode_label = Label(frame4, text="Select all platforms \n this game is available for:")
self.mode_label.pack(side=LEFT, padx=5, pady=5)
self.listbox = Listbox(frame4, selectmode='multiple', activestyle='dotbox', height=4, borderwidth=2, highlightcolor='green')
self.listbox.pack(side=LEFT, pady=5, padx=10)
for item in ["Windows", "PS4", "Xbox One", "WiiU"]:
self.listbox.insert(END, item)
self.price_label = Label(frame6, text="Price", relief='groove')
self.price_label.pack(side=LEFT, padx=5, pady=5)
self.pSpinBox = Spinbox(frame6, values=('5','10','15','20','25','30'), width=8)
self.pSpinBox.pack(side=LEFT, pady=5, padx=10)
self.addbtn = Button(frame6, text="Add game", command=self._addbtn_btn_clicked, fg='green', activebackground= 'green')
self.addbtn.pack(side=LEFT, padx=40, pady=5)
def _addbtn_btn_clicked(self):
gameName = self.game_entry.get()
genre = self.genreBox.get()
rating = self.ratingBox.get()
publisher = self.publisherBox.get()
release = self.release_entry.get()
price = self.pSpinBox.get()
stock = 100
SinglePlayer = self.spSpinBox.get()
MultiPlayer = self.mpSpinBox.get()
Windows = 'FALSE'
PS4 = 'FALSE'
XboxOne = 'FALSE'
WiiU = 'FALSE'
if SinglePlayer == 'Yes':
SinglePlayer = 'TRUE'
else:
SinglePlayer = 'FALSE'
if MultiPlayer == 'Yes':
MultiPlayer = 'TRUE'
else:
MultiPlayer = 'FALSE'
if 0 in self.listbox.curselection():
Windows = 'TRUE'
if 1 in self.listbox.curselection():
PS4 = 'TRUE'
if 2 in self.listbox.curselection():
XboxOne = 'TRUE'
if 3 in self.listbox.curselection():
WiiU = 'TRUE'
def CheckUserExists(gameName):
c.execute("SELECT name FROM games WHERE name=?", (gameName,))
data = c.fetchall()
if not data:
return False
else:
return True
if CheckUserExists(gameName) == True:
pu.onGameExists()
else:
if len(gameName) == 0 or len(release) == 0:
pu.onNull()
else:
c.execute('INSERT INTO games VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (gameName, genre, rating, publisher, release, SinglePlayer, MultiPlayer, \
Windows, PS4, XboxOne, WiiU, stock, price))
db.commit()
if publisher != 'Other':
pu.onGameAdded()
elif publisher == 'Other':
pu.onOtherPub()
import Publisher
Publisher.root.deiconify()
root = Tk()
def on_closing():
root.withdraw()
root.protocol("WM_DELETE_WINDOW", on_closing)
pu = Popup(parent=root)
root.geometry("550x275+300+300")
lf = AddFrame(root)
root.mainloop()