MVC¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶
27
from browser import document, html
def save_data(event):
# Add your save data logic here
print(f"Destination: {destination.value}, Description: {description.value}, Speak to: {address.value}")
app = html.DIV()
app <= html.H2('HEAD-Ex Logistics and Transport')
app <= html.LABEL('Destination: ')
destination = html.INPUT()
app <= destination
app <= html.LABEL('Description: ')
description = html.INPUT()
app <= description
app <= html.LABEL('Speak to: ')
address = html.INPUT()
app <= address
button = html.BUTTON('Save')
button.bind('click', save_data)
app <= button
Activity: 1 ActiveCode (ac_l52_1a_en)
HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

Model is the stored data
Vision is the featured radio button
Control is the tkinter code that manages all this
19
from browser import document, html
def on_change(event):
print(f"Destination: {event.target.value}")
app = html.DIV()
app <= html.LABEL('Destination: ')
destinations = ['Cambridge, MA', 'Cambridge, UK', 'Seattle, WA']
for destination in destinations:
radio = html.INPUT(Type="radio", name="destination", value=destination)
radio.bind('change', on_change)
app <= radio
app <= html.LABEL(destination)
app <= html.BR()
document <= app
Activity: 2 ActiveCode (ac_l52_1b_en)
HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶
36
from browser import document, html, window
def save_data(event):
window.localStorage['Destination'] = destination.value
window.localStorage['Description'] = description.value
window.localStorage['Address'] = address.value
destination.value = ''
description.value = ''
address.value = ''
def read_destinations():
destinations = []
for key in window.localStorage:
destinations.append(window.localStorage[key])
return destinations
app = html.DIV()
app <= html.LABEL('Destination: ')
destination = html.INPUT()
app <= destination
app <= html.LABEL('Description: ')
description = html.INPUT()
Activity: 3 ActiveCode (ac_l52_1c_en)
HEAD-Ex Logistics and Transportation¶
35
from browser import document, html, window, console
def save_data(event):
window.localStorage['Destination'] = destination.value
window.localStorage['Description'] = description.value
window.localStorage['Address'] = address.value
console.log(f"Saved data: Destination - {destination.value}, Description - {description.value}, Address - {address.value}")
destination.value = ''
description.value = ''
address.value = ''
app = html.DIV()
app <= html.H2('HEAD-Ex Logistics and Transport')
app <= html.LABEL('Destination: ')
destination = html.SELECT()
options = ["Option 1", "Option 2", "Option 3"] # Replace with your options
for option in options:
destination <= html.OPTION(option)
app <= destination
app <= html.LABEL('Description: ')
description = html.INPUT()
app <= description
Activity: 4 ActiveCode (ac_l52_1d_en)
HEAD-Ex Logistics and Transportation¶

Review¶
MVC - Model, View, Control
Entry()
Texto()
StringVar()
RadioButton()
OptionMenu()
You have attempted 1 of 5 activities on this page