-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
184 lines (152 loc) · 4.32 KB
/
main.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
from turtle import color
import flet as ft
from src.utils.verificar import revisar_codigo, encontrar_x, consultar_codigo
BG = '#041955'
FG = '#3450a1'
PINK= '#eb06ff'
FWG = '#97b4ff'
RED = '#ff0000'
fondo = '#041955'
def contenedor_text(texto):
return ft.Container(
width=250,
height=200,
bgcolor= FG,
border_radius=35,
alignment=ft.alignment.center,
padding=ft.padding.only(20,20,20,20),
content=texto,
border=ft.Border(top=ft.BorderSide(color=PINK, width=2), bottom=ft.BorderSide(color=PINK, width=2))
)
def main(page: ft.Page):
page.title = "Verificador de codigo"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.bgcolor = fondo
# ____Gerenal____
tipo_codigo = ft.Text("", color='white', size=20, text_align=ft.TextAlign.CENTER)
codigo = ft.TextField(label="Codigo")
# _______Menu________
def route_change(e: ft.RouteChangeEvent):
page.clean()
page.add(opciones)
if e.route == "/":
page.add(verificando)
elif e.route == "/revisar":
page.add(consultar)
elif e.route == "/encontrar_x":
page.add(encontrar_x_contenido)
def mover(e, valor):
page.route = valor
page.update()
main = ft.ElevatedButton(text="Verificar", on_click=lambda e: mover(e,"/"), bgcolor=BG, color='white')
revisar = ft.ElevatedButton(text="Revisar", on_click=lambda e: mover(e,"/revisar"), bgcolor=BG, color='white')
digito_control = ft.ElevatedButton(text="Buscar X", on_click=lambda e: mover(e,"/encontrar_x"), bgcolor=BG, color='white')
opciones = ft.Container(
bgcolor=FWG,
padding=ft.padding.only(10,20,10,20),
border_radius=20,
width=400,
content=ft.Row(
controls=[main, revisar, digito_control],
alignment=ft.MainAxisAlignment.CENTER,
)
)
# ____ main______
def analizar_codigo(e):
print(codigo.value)
tipo_codigo.value = revisar_codigo(codigo.value)
page.update()
boton_verificar = ft.ElevatedButton(
color= 'white',
text="Verificar",
on_click=analizar_codigo
)
verificando = ft.Container(
width=400,
height=550,
bgcolor= FG,
border_radius=35,
padding=ft.padding.only(20,50,20,50),
content= ft.Column(
controls=[
ft.Text("Ingrese el codigo a verificar"),
codigo,
boton_verificar,
contenedor_text(tipo_codigo)
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
)
# ____Revisar____
def consultar_codigo_tipo(e):
tipo_codigo.value = str(consultar_codigo(codigo.value, escoger_codigo.value))
page.update()
boton_consultar = ft.ElevatedButton(
color= 'white',
text="Consultar",
on_click=consultar_codigo_tipo
)
escoger_codigo = ft.Dropdown(
label="tipo",
hint_text="tipo de codigo a verificar",
options=[
ft.dropdown.Option("ISIN"),
ft.dropdown.Option("ISBN-10"),
ft.dropdown.Option("ISBN-13"),
ft.dropdown.Option("EAN-8"),
ft.dropdown.Option("EAN-13"),
],
border_radius=20,
bgcolor=FWG,
alignment=ft.alignment.center,
autofocus=True,
)
consultar = ft.Container(
width=400,
height=550,
bgcolor= FG,
border_radius=35,
padding=ft.padding.only(20,50,20,50),
content=ft.Column(
controls=[
ft.Text("Ingrese el codigo a consultar"),
codigo,
escoger_codigo,
boton_consultar,
contenedor_text(tipo_codigo)
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
))
# ____Encontrar X____
def buscar_x(e):
tipo_codigo.value = str(encontrar_x(codigo.value))
page.update()
boton_encontrar_x = ft.ElevatedButton(
color= 'white',
text="Encontrar X",
on_click=buscar_x
)
encontrar_x_contenido = ft.Container(
width=400,
height=550,
bgcolor= FG,
border_radius=35,
padding=ft.padding.only(20,50,20,50),
content=ft.Column(
controls=[
ft.Text("Ingrese el codigo a buscar el valor de X"),
codigo,
boton_encontrar_x,
contenedor_text(tipo_codigo)
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
)
# ____Configuracion de la pagina____
page.on_route_change = route_change
page.add(opciones)
page.add(verificando)
ft.app(target=main)