-
Notifications
You must be signed in to change notification settings - Fork 8
/
gui.py
133 lines (104 loc) · 3.68 KB
/
gui.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
import tkinter as tk
from tkinter import Frame, Entry, Listbox
import csv
import json
from classes.skinport import skinport
from classes.buff import Buff
skin_names = []
with open("csv/skins.csv", "r", encoding="utf-8") as f:
reader = csv.reader(f)
for row in reader:
skin_names.append(row[0])
skin_names = skin_names[1:]
with open("config.json", "r") as f:
config = json.load(f)
b = Buff(config["Cookies"])
s = skinport()
def checkKey(event):
value = event.widget.get()
if value == '':
data = skin_names
skinList.pack_forget()
else:
errorMessage.pack_forget()
submitButton.pack_forget()
skinList.pack(padx=20)
submitButton.pack(pady=30)
data = []
for item in skin_names:
if value.lower() in item.lower():
data.append(item)
update(data)
def update(data):
skinList.delete(0, 'end')
for item in data:
skinList.insert('end', item)
def displayError(text):
submitButton.pack_forget()
errorMessage.config(text=text)
errorMessage.pack(pady=10)
submitButton.pack(pady=30)
def Submit():
try:
selectedIndex = skinList.curselection()
selectedItem = skinList.get(selectedIndex[0])
errorMessage.pack_forget()
try:
sp = s.getSkinportPrice(selectedItem)
buff = b.getBuffPrice(selectedItem)
afterFees = round((buff - (buff * 0.025)),2) #after fees Buff
profit = round(afterFees - sp,2)
gain = round((profit / sp) * 100,6)
results = [selectedItem, '$'+str(sp), '$'+str(buff), '$'+str(afterFees), str(profit), str(gain)+'%']
updateResults(results)
except:
displayError("Please try another skin. Value not found")
except:
displayError("Please enter a skin")
def updateResults(results):
skinName.config(text=results[0])
spPrice.config(text=f"Skinport: {results[1]}")
buffPrice.config(text=f"Buff: {results[2]}")
afterFees.config(text=f"After Fees: {results[3]}")
if(float(results[4]) < 0):
profit.config(text=f"Profit: ${results[4]}", fg="red")
gain.config(text=f"Gain: {results[5]}", fg="red")
else:
profit.config(text=f"Profit: ${results[4]}", fg="green")
gain.config(text=f"Gain: {results[5]}", fg="green")
skinName.pack()
spPrice.pack()
buffPrice.pack()
afterFees.pack()
profit.pack()
gain.pack()
app = tk.Tk()
app.title("spToBuff")
app.resizable(False, False)
app.geometry("800x450")
app.minsize(800,450)
app.maxsize(800,450)
app.configure(bg="lightgray")
selectFrame = Frame(app, width=300, height=450, bg="lightgray")
selectFrame.pack(side="left", fill="both", expand=True,pady=30)
resultFrame = Frame(app, width=500, height=450, bg="lightgray")
resultFrame.pack(side="right", fill="both", expand=True, pady=(30,0), padx=30)
selectFrame.pack_propagate(False)
resultFrame.pack_propagate(False)
label = tk.Label(selectFrame, text="Select a skin:", font=("Arial", 12))
label.pack(pady=10)
skinEntry = Entry(selectFrame, width=50)
skinEntry.bind("<KeyRelease>", checkKey)
skinEntry.pack(padx = 20)
skinList = Listbox(selectFrame, width=50)
update(skin_names)
errorMessage = tk.Label(selectFrame, fg="red")
submitButton = tk.Button(selectFrame, text="Submit", font=("Arial", 12), command=Submit)
submitButton.pack(pady=30)
skinName = tk.Label(resultFrame, font=("Arial", 12))
spPrice = tk.Label(resultFrame, font=("Arial", 12))
buffPrice = tk.Label(resultFrame, font=("Arial", 12))
afterFees = tk.Label(resultFrame, font=("Arial", 12))
profit = tk.Label(resultFrame, font=("Arial", 12))
gain = tk.Label(resultFrame, font=("Arial", 12))
app.mainloop()