In this era of rich browser applications, everybody needs to know at least enough about events to write an ‘
- Founder of Twisted
- has been doing event-driven architecture since he was 8 years old
- Not stupid enough to attempt live-coding while on stage.
Code samples too dense to jot down during live-noting.
- Comparing Arrays
- Adding numbers
- Defining types
- Loading Modules
- Calling functions
- Handling events
A Tale of Two Events¶
- asynchronous I/O
- Clicky buttons
When X -> Do Y¶
- Event driven architecture is incredibly simple. When X, then do Y.
- When I click -> Do Say “hi”
HTML Event-Driven Example¶
<!DOCTYPE html> <button onclick="alert(this.innerHTML);" Hello, world! </button>
PyJS (Most complete Python in browser)¶
- Widget toolkit
# TODO Add imports def hello_world(button): alert(button.getHTML()) b = Button("Hello, world") b.addClickListener(hello_world) # TODO Finish
# TODO Add imports def alert(txt): lbl = Text() btn = Button("OK") vert = V.VerticalPanel() # TODO Finish