-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
136 lines (122 loc) · 6.19 KB
/
client.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
from tkinter import *
from tkinter import ttk, font
import requests
class Aplication(Tk):
def __init__(self, title):
super().__init__()
self.title(title)
self.state('zoomed')
self.fuente = font.Font(weight='bold',size=25)
self.default = StringVar(self)
self.default.set(0)
self.qty = ttk.Label(self,text='Catidad de datos',font=self.fuente)
self.box = ttk.Spinbox(self,from_=0,to=20,width=2,textvariable=self.default,font=self.fuente)
self.temperatureButton = ttk.Button(self,text='Temperatura',command=self.getTemperature,padding=(20,20))
self.humidityButton = ttk.Button(self,text='Humedad',command=self.getHummidity,padding=(20,20))
self.pressureButton = ttk.Button(self,text='Presión',command=self.getPressure,padding=(20,20))
self.returnButton = ttk.Button(self,text='Regresar',command=self.goBack,padding=(20,20))
self.qty.place(relx=0.5,rely=0.35,anchor=CENTER)
self.box.place(relx=0.5,rely=0.42,anchor=CENTER)
self.temperatureButton.place(relx=0.25,rely=0.55,anchor=CENTER)
self.humidityButton.place(relx=0.5,rely=0.55,anchor=CENTER)
self.pressureButton.place(relx=0.75,rely=0.55,anchor=CENTER)
self.mainloop()
def getTemperature(self):
self.boxValue = int(self.box.get())
self.temperatureButton.place_forget()
self.humidityButton.place_forget()
self.pressureButton.place_forget()
self.qty.place_forget()
self.box.place_forget()
self.frame = ttk.Frame(self,borderwidth=5,relief="raised",padding=(10,10))
self.frame.place(relx=0.5,rely=0.5,anchor=CENTER)
self.returnButton.place(relx=0.5,rely=0.8,anchor=CENTER)
column1Title = ttk.Label(self.frame,text='Temperature')
column2Title = ttk.Label(self.frame,text='Date')
column1Title.grid(column=0,row=0,padx=10,pady=10)
column2Title.grid(column=1,row=0,padx=10,pady=10)
queryString : str = "http://localhost:8080/values/?type=temperature&size=" + str(self.boxValue)
data = requests.get(url = queryString)
response : str = data.text
Temperature = []
date = []
print(response)
for x in range(self.boxValue):
Temperature.append(response[response.find(":") + 1 : response.find(",")])
date.append(response[response.find("\"time\":") + len("\"time\":\"") : response.find("\"}")])
response = response[response.find("}")+2:]
for x in range(self.boxValue):
column0 = ttk.Label(self.frame,text=Temperature[x])
column1 = ttk.Label(self.frame,text=date[x])
column0.grid(column=0,row=x+1,padx=10,pady=10)
column1.grid(column=1,row=x+1,padx=10,pady=10)
def getHummidity(self):
self.boxValue = int(self.box.get())
self.temperatureButton.place_forget()
self.humidityButton.place_forget()
self.pressureButton.place_forget()
self.qty.place_forget()
self.box.place_forget()
self.frame = ttk.Frame(self,borderwidth=5,relief="raised",padding=(10,10))
self.frame.place(relx=0.5,rely=0.5,anchor=CENTER)
self.returnButton.place(relx=0.5,rely=0.8,anchor=CENTER)
column1Title = ttk.Label(self.frame,text='Humidity')
column2Title = ttk.Label(self.frame,text='Date')
column1Title.grid(column=0,row=0,padx=10,pady=10)
column2Title.grid(column=1,row=0,padx=10,pady=10)
queryString : str = "http://localhost:8080/values/?type=humidity&size=" + str(self.boxValue)
data = requests.get(url = queryString)
response : str = data.text
Humidity = []
date = []
for x in range(self.boxValue):
Humidity.append(response[response.find(":") + 1 : response.find(",")])
date.append(response[response.find("\"time\":") + len("\"time\":\"") : response.find("\"}")])
response = response[response.find("}")+2:]
for x in range(self.boxValue):
column0 = ttk.Label(self.frame,text=Humidity[x])
column1 = ttk.Label(self.frame,text=date[x])
column0.grid(column=0,row=x+1,padx=10,pady=10)
column1.grid(column=1,row=x+1,padx=10,pady=10)
def getPressure(self):
self.boxValue = int(self.box.get())
self.temperatureButton.place_forget()
self.humidityButton.place_forget()
self.pressureButton.place_forget()
self.qty.place_forget()
self.box.place_forget()
self.frame = ttk.Frame(self,borderwidth=5,relief="raised",padding=(10,10))
self.frame.place(relx=0.5,rely=0.5,anchor=CENTER)
self.returnButton.place(relx=0.5,rely=0.8,anchor=CENTER)
column1Title = ttk.Label(self.frame,text='Pressure')
column2Title = ttk.Label(self.frame,text='Date')
column1Title.grid(column=0,row=0,padx=10,pady=10)
column2Title.grid(column=1,row=0,padx=10,pady=10)
queryString : str = "http://localhost:8080/values/?type=pressure&size=" + str(self.boxValue)
data = requests.get(url = queryString)
response : str = data.text
Pressure = []
date = []
print(response)
for x in range(self.boxValue):
Pressure.append(response[response.find(":") + 1 : response.find(",")])
date.append(response[response.find("\"time\":") + len("\"time\":\"") : response.find("\"}")])
response = response[response.find("}")+2:]
for x in range(self.boxValue):
column0 = ttk.Label(self.frame,text=Pressure[x])
column1 = ttk.Label(self.frame,text=date[x])
column0.grid(column=0,row=x+1,padx=10,pady=10)
column1.grid(column=1,row=x+1,padx=10,pady=10)
def goBack(self):
self.returnButton.place_forget()
self.frame.destroy()
self.temperatureButton.place(relx=0.25,rely=0.5,anchor=CENTER)
self.humidityButton.place(relx=0.5,rely=0.5,anchor=CENTER)
self.pressureButton.place(relx=0.75,rely=0.5,anchor=CENTER)
self.qty.place(relx=0.5,rely=0.35,anchor=CENTER)
self.box.place(relx=0.5,rely=0.42,anchor=CENTER)
def main():
app = Aplication('Estación Meteorologica')
return 0
if __name__ == '__main__':
main()