MVC¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶
27
from browser import document, html
def guardar_datos(evento):
# Agrega tu lógica para guardar datos aquí
print(f"Destino: {destino.value}, Descripción: {descripcion.value}, Hablar a: {direccion.value}")
app = html.DIV()
app <= html.H2('HEAD-Ex Logística y Transporte')
app <= html.LABEL('Destino: ')
destino = html.INPUT()
app <= destino
app <= html.LABEL('Descripción: ')
descripcion = html.INPUT()
app <= descripcion
app <= html.LABEL('Hablar a: ')
direccion = html.INPUT()
app <= direccion
boton = html.BUTTON('Guardar')
boton.bind('click', guardar_datos)
app <= boton
Activity: 1 ActiveCode (ac_l52_1a)
HEAD-Ex Logística e Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

Modelo son los datos almacenados
Vision es el botón de radio presentado
Control es el código tkinter que gestiona todo esto
19
from browser import document, html
def al_cambiar(evento):
print(f"Destino: {evento.target.value}")
app = html.DIV()
app <= html.LABEL('Destino: ')
destinos = ['Cambridge, MA', 'Cambridge, UK', 'Seattle, WA']
for destino in destinos:
radio = html.INPUT(Type="radio", name="destino", value=destino)
radio.bind('change', al_cambiar)
app <= radio
app <= html.LABEL(destino)
app <= html.BR()
document <= app
Activity: 2 ActiveCode (ac_l52_1b)
HEAD-Ex Logística e Transporte¶

HEAD-Ex Logística e Transporte¶
36
from browser import document, html, window
def guardar_datos(evento):
window.localStorage['Destino'] = destino.value
window.localStorage['Descripción'] = descripcion.value
window.localStorage['Dirección'] = direccion.value
destino.value = ''
descripcion.value = ''
direccion.value = ''
def leer_destinos():
destinos = []
for clave in window.localStorage:
destinos.append(window.localStorage[clave])
return destinos
app = html.DIV()
app <= html.LABEL('Destino: ')
destino = html.INPUT()
app <= destino
app <= html.LABEL('Descripción: ')
descripcion = html.INPUT()
Activity: 3 ActiveCode (ac_l52_1c)
HEAD-Ex Logística e Transporte¶
35
from browser import document, html, window, console
def guardar_datos(evento):
window.localStorage['Destino'] = destino.value
window.localStorage['Descripción'] = descripcion.value
window.localStorage['Dirección'] = direccion.value
console.log(f"Datos guardados: Destino - {destino.value}, Descripción - {descripcion.value}, Dirección - {direccion.value}")
destino.value = ''
descripcion.value = ''
direccion.value = ''
app = html.DIV()
app <= html.H2('HEAD-Ex Logística y Transporte')
app <= html.LABEL('Destino: ')
destino = html.SELECT()
opciones = ["Opción 1", "Opción 2", "Opción 3"] # Reemplaza con tus opciones
for opcion in opciones:
destino <= html.OPTION(opcion)
app <= destino
app <= html.LABEL('Descripción: ')
descripcion = html.INPUT()
app <= descripcion
Activity: 4 ActiveCode (ac_l52_1d)
HEAD-Ex Logística y Transporte¶

revisión¶
MVC - Modelo, Visión, Control
Entry()
Texto()
StringVar()
RadioButton()
OptionMenu()
You have attempted 1 of 5 activities on this page