@@ -14,6 +14,7 @@ def __init__(self, pantalla: Ventana, Dispostivo: Arduino, caja: tkinter.Listbox
14
14
self .dispositivo : Arduino = Dispostivo
15
15
self .caja = caja
16
16
self .ventanas : Ventana = pantalla
17
+ self .values_x : list = []
17
18
18
19
#Funcionalidades para realizar la regresion:
19
20
def __boton_regresion (self , posx : float , posy : float , size : str ) -> tkinter .Button :
@@ -79,14 +80,26 @@ def __regresion(self, size: str) -> None:
79
80
Realizar = tkinter .Button (
80
81
nueva , text = "Realizar" , command = lambda : self .__regresion_datos (
81
82
etiqueta1 , etiqueta2 , etiqueta3 , etiqueta4 , etiqueta5 , pantalla = nueva , estado1 = opcion , estado2 = opcion2
82
- ), bg = 'lightgreen'
83
+ ), bg = 'lightgreen' , state = "disabled"
83
84
)
84
85
Realizar .place (relx = 0.36 , rely = 0.85 )
85
86
# eliminar datos ingresados:
86
87
reset = tkinter .Button (
87
88
nueva , text = "Reset" , command = lambda : self .__reset (nueva ), bg = 'indian red'
88
89
)
89
90
reset .place (relx = 0.53 , rely = 0.85 )
91
+ # desactivar opciones por un cierto tiempo:
92
+ self .dispositivo .limpiar ()
93
+ self .dispositivo .escribir_datos ("[true/8]" )
94
+ self .pantalla .after (self .dispositivo .Guardar .tiempo , self .__activar_Valores , Realizar )
95
+
96
+ def __activar_Valores (self , boton : tkinter .Button ) -> None :
97
+ self .values_x = self .dispositivo .leer_valores_celdad_carga ()
98
+ boton .config (state = "active" )
99
+ if len (self .values_x ) == 5 :
100
+ self .caja .insert (tkinter .END , "Se recivieron los datos." )
101
+ else :
102
+ self .caja .insert (tkinter .END , "No se recivieron los datos." )
90
103
91
104
def __estado (self , estado : tkinter .IntVar , boton : tkinter .Checkbutton , estado2 : tkinter .IntVar ):
92
105
if (estado .get () == 1 and estado2 .get () == 1 ):
@@ -123,23 +136,34 @@ def __regresion_datos(self, *args: tkinter.StringVar, pantalla: tkinter.Toplevel
123
136
self .caja .insert (tkinter .END , "Intente de nuevo" )
124
137
break
125
138
else :
126
- if ( indx == 4 ) :
127
- list1 : list = [- 2 , 1 , 4 , 3 , 0 ]
139
+ if indx == 4 and len ( self . values_x ) == 5 :
140
+ # list1: list = [-2, 1, 4, 3, 0]
128
141
aux : str = self .__definir (estado1 , estado2 )
129
- regresion_final : list = realizar (aux , list1 , lista )
142
+ regresion_final : list = realizar (aux , self . values_x , lista )
130
143
self .caja .insert (
131
144
tkinter .END , "Valores de la Regresion {}:" .format (aux ))
132
145
for element in regresion_final :
133
146
self .caja .insert (
134
147
tkinter .END , "{:.2f}" .format (element ))
135
148
self .dispositivo .Regresion (element )
136
- self .pantalla .after (1400 , self .confirmar )
137
- self .caja .insert (
138
- tkinter .END , "Regresion configurada" )
149
+ self .pantalla .after (2000 , self .valorar_regresion )
139
150
pantalla .destroy ()
151
+ elif len (self .values_x ) < 5 :
152
+ for widget in pantalla .winfo_children ():
153
+ if isinstance (widget , tkinter .Button ):
154
+ if widget .config ('text' )[- 1 ] == "Realizar" :
155
+ self .__activar_Valores (widget )
156
+ break
157
+ self .caja .insert (tkinter .END , "Valores del eje x no han sido recividos aún completos" )
140
158
else :
141
159
pass
142
160
161
+ def valorar_regresion (self ):
162
+ if self .dispositivo .confirmar_regresion ():
163
+ self .caja .insert (tkinter .END , "Regresion configurada" )
164
+ else :
165
+ self .caja .insert (tkinter .END , "Regresion No configurada" )
166
+
143
167
def regresion (self , posx : float , posy : float , size : str ) -> None :
144
168
self .__boton_regresion (posx , posy , size )
145
169
@@ -178,6 +202,7 @@ def conection_arduino(self) -> None:
178
202
aux .config (state = "disabled" )
179
203
var .set (self .dispositivo .Port ())
180
204
self .caja .insert (tkinter .END , self .dispositivo .conexion )
205
+ self .dispositivo .limpiar ()
181
206
182
207
#Boton para obtener las opciones:
183
208
def menu_opciones_conexion (self , var : tkinter .StringVar , port : list ) -> tkinter .OptionMenu :
@@ -209,6 +234,7 @@ def __conectar(self, var: tkinter.StringVar, etiqueta: tkinter.Label, var2: tkin
209
234
elif isinstance (widget , tkinter .Entry ):
210
235
widget .config (state = "disabled" )
211
236
self .caja .insert (tkinter .END , self .dispositivo .conexion )
237
+ self .dispositivo .limpiar ()
212
238
else :
213
239
self .caja .insert (tkinter .END , self .dispositivo .Errores )
214
240
0 commit comments