-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenu.py
158 lines (124 loc) · 6.07 KB
/
MainMenu.py
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
from additem import additemobject
from sql import sql__firstlastname__fetch
from sql import sql__myrating__fetch
from sql import sql__unacceptedswaps__fetch
from sql import sql__fivedayoldswap__fetch
from sql import sql__unratedswaps__fetch
from my_Items import my_items
def MainMenuObject(user_email):
#if __name__ == '__main__':
import tkinter as tk
import sys
import os
#from tkinter import *
from tkinter import ttk
from tkmacosx import Button
import pandas as pd
from functools import partial
from IPython.display import display
import mysql.connector
cnx = mysql.connector.connect(user='team103', password='gatech123',
host='127.0.0.1',
database='CS6400_spr22_team103')
import pandas as pd
# creates a Tk() object
master = tk.Tk()
master.title("GameSwap")
master.resizable(width=False, height=False)
#clickvalue=''
# sets the geometry of main
# root window
master.geometry("500x500")
def logout():
master.destroy()
label_title = tk.Label(master,text="GameSwap")
label_title.place(width=100,height=35,x=50,y=50)
label_title.config(font=("Courier", 15,'bold'))
label_underline = tk.Label(master,text="----------------------------------------------------------------------------------------------------------------")
label_underline.place(width=400,height=50,x=50,y=85)
label_underline.config(font=("Courier", 5,'bold'))
logout_button = Button(master,
text="Logout", bg='blue',fg='white', borderless=1,command=logout)
logout_button.place(x=400,y=30)
first_last_name_fetch_query=sql__firstlastname__fetch(user_email)
first_last_name_data = []
first_last_name_data = pd.read_sql_query(first_last_name_fetch_query, cnx)
print(first_last_name_fetch_query)
myrating_fetch_query=sql__myrating__fetch(user_email)
myrating_data = []
myrating_data = pd.read_sql_query(myrating_fetch_query, cnx)
print(myrating_fetch_query)
unacceptedswaps_fetch_query=sql__unacceptedswaps__fetch(user_email)
unacceptedswaps_data = []
unacceptedswaps_data = pd.read_sql_query(unacceptedswaps_fetch_query, cnx)
fivedayoldswaps_fetch_query = sql__fivedayoldswap__fetch(user_email)
fivedayoldswaps_data = []
fivedayoldswaps_data = pd.read_sql_query(fivedayoldswaps_fetch_query, cnx)
print(myrating_data)
unratedswaps_fetch_query = sql__unratedswaps__fetch(user_email)
unratedswaps_data = []
print(unratedswaps_fetch_query)
unratedswaps_data = pd.read_sql_query(unratedswaps_fetch_query, cnx)
def myitems():
my_items(user_email)
#os.system('my_Items.py')
def additem():
additemobject(user_email)
#os.system('additem.py')
def searchitems():
os.system('searchitems.py')
def acceptorrejectswaps():
if int(unacceptedswaps_data['unaccepted_swaps'][0]) > 0:
#accept_reject_swaps(userEmail)
os.system('searchitems.py')
def propose_swaps():
os.system('propose_swap.py')
def unrated_swaps():
if int(unratedswaps_data['unrated_swaps'][0]) > 0:
os.system('rateswaps.py')
def swaphistory():
os.system('swaphistory.py')
def updatemyinfo():
os.system('UpdateMyInfo.py')
label_logged_user = tk.Label(master,text="Welcome " + str(first_last_name_data['name'][0]))
label_logged_user.place(width=300,height=35,x=50,y=125)
label_logged_user.config(font=("Times Roman", 10,'bold'))
myrating_text=tk.StringVar()
myrating_text.set("My Rating-"+str(myrating_data['user_rating'][0]))
myrating_button = Button(master,
text=myrating_text.get(), bg='white',fg='blue', borderless=1,height=50,width=150)
myrating_button.place(x=50,y=150)
myrating_button.config(fg='blue', font=("Courier", 10))
listitem_button = Button(master,
text="List Item", bg='blue',fg='white', borderless=1,height=50,width=150,command=additem)
listitem_button.place(x=210,y=150)
unacceptedswaps_text=tk.StringVar()
unacceptedswaps_text.set("Unaccepted Swaps-"+str(unacceptedswaps_data['unaccepted_swaps'][0]))
unacceptedswaps_button = Button(master,
text=unacceptedswaps_text.get(), bg='white',fg='blue', borderless=1,height=50,width=150,command=acceptorrejectswaps)
unacceptedswaps_button.place(x=50,y=200)
if unacceptedswaps_data['unaccepted_swaps'][0] > 4 or fivedayoldswaps_data['fivedayoldswaps'][0] >0 :
unacceptedswaps_button.config(fg='red', font=("Courier", 10, 'bold'))
else:
unacceptedswaps_button.config(fg='blue', font=("Courier", 10))
myitems_button = Button(master,text="My Item", bg='blue',fg='white', borderless=1,height=50,width=150,command=myitems)
myitems_button.place(x=210,y=200)
unratedswaps_text=tk.StringVar()
unratedswaps_text.set("Unrated Swaps-"+str(unratedswaps_data['unrated_swaps'][0]))
unratedswaps_button = Button(master,
text=unratedswaps_text.get(), bg='white',fg='blue', borderless=1,height=50,width=150,command=unrated_swaps)
unratedswaps_button.place(x=50,y=250)
if unratedswaps_data['unrated_swaps'][0] > 1:
unratedswaps_button.config(fg='red',font=("Courier", 10,'bold'))
else:
unratedswaps_button.config(fg='blue', font=("Courier", 10))
searchitems_button = Button(master,
text="Search Items", bg='blue',fg='white', borderless=1,height=50,width=150,command=searchitems)
searchitems_button.place(x=210,y=250)
swaphistory_button = Button(master,
text="Swap History", bg='blue',fg='white', borderless=1,height=50,width=150,command=swaphistory)
swaphistory_button.place(x=210,y=300)
updatemyinfo_button = Button(master,
text="Update my info", bg='blue',fg='white', borderless=1,height=50,width=150,command=updatemyinfo)
updatemyinfo_button.place(x=210,y=350)
tk.mainloop()