-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrenador.py
More file actions
69 lines (60 loc) · 1.82 KB
/
entrenador.py
File metadata and controls
69 lines (60 loc) · 1.82 KB
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
from tkinter import *
from red import *
ventana = Tk()
arch = open("sal.txt", "w+")
arch.close()
class Check():
def __init__(self, ventana, i, j):
self.valor = IntVar()
Checkbutton(
ventana, variable = self.valor).grid(row = i, column = j)
class UI:
def __init__(self, ventana, red, datos):
self.checks = []
for i in range (1, 8):
for j in range(1, 7):
self.checks.append(Check(ventana, i , j))
boton_reconocer = Button(ventana, text = "RECONOCER", command = self.reconoce)
boton_reconocer.grid(row = 9 , column = 9)
Label (ventana, text = "Es el numero: ").grid(row = 10, column = 9)
b_limpiar = Button(ventana, text = "LIMPIAR", command = self.limpiar)
b_limpiar.grid(row = 12, column = 9)
b_ent = Button(ventana, text = "ENTRENAR", command = self.entrena)
b_ent.grid(row = 13, column = 9)
b_es = Button(ventana, text = "ESCRIBE EN ARCHIVO", command = self.escribe)
b_es.grid(row = 14, column = 19)
def reconoce(self):
aux = ""
for check in self.checks:
aux = aux + " " + str(check.valor.get()) + " /"
entrada = aux[0:len(aux)-1]
out = red.reconocer(Matriz(entrada)).to_s()
out = bin_dec(out)
Label (ventana, text = str(out)).grid(row = 11, column = 9)
def limpiar(self):
ui = UI(ventana, red, datos)
def entrena(self):
red.entrenar( datos.cargar() )
def escribe(self):
arch = open("sal.txt", "a")#a
sal = "\n\t\tself.tipos.append(Tipo (self.cad_fm (\n\t\t\t\t\t\t\t \""
i=1
for check in self.checks:
#print (check.valor.get())
if check.valor.get() == 0:
valor = "."
else:
valor = "1"
if i==7:
sal = sal + "\" +\n\t\t\t\t\t\t\t \""
i = 1
sal = sal+valor
i = i+1
sal = sal + "\" ) , \"1 / 0 / 0 / 1\"))"
print (sal)
arch.write(sal)
red=Red()
datos=Datos()
red.entrenar(datos.cargar())
ui = UI(ventana, red, datos)
mainloop()