CS260 Event Driven Programming Dick Steflik What is

  • Slides: 14
Download presentation
CS-260 Event Driven Programming Dick Steflik

CS-260 Event Driven Programming Dick Steflik

What is it? • Program execution is determined by user or sensor generated events

What is it? • Program execution is determined by user or sensor generated events rather than the old linear (begining to end) execution of command line programs. • Execution is non-linear

Embedded Systems • Interrupts – these are usually sensor generated asynchronous real-world events. •

Embedded Systems • Interrupts – these are usually sensor generated asynchronous real-world events. • Usually handled by an ISS (Interrupt Servicing Subroutine) that gains control via a hardware controlled vector (automatic hardware branch). • Ex. A microcontroller based humidifier that has a low water interrupt that automatically puts the device into a non-damaging state when it runs out of water and displays a low water message.

Event Handling • The IBM Series 1 (circa 1980 s) process control computer was

Event Handling • The IBM Series 1 (circa 1980 s) process control computer was one of the first event driven computers, it responded to external sensor generated events and was used to control industrial processes. – Programmed via EDL (Event Driven Language). – For each possible event a handler was provided, a typical program would initialize the environment then enter a do forever loop. When an event occurred, program control would transfer from the loop to the appropriate handler, execute the handler then return to the loop.

GUI Event Processing • With the advent of the personal computer and the modern

GUI Event Processing • With the advent of the personal computer and the modern day Graphical User Interface the model used for Event Processing in process control applications was extended to the GUI. – Initialize the environment register the event generators loop forever (wait for an event) – when an even occurs, put it into the event queue – the dispatcher will examine the next event in the queue and invoke the correct handler

Initializing the Environment • Mask off all events (don’t allow events) • Register all

Initializing the Environment • Mask off all events (don’t allow events) • Register all of the widgets that create events – what they are, where they are, names • Register the event handlers – bind the various events to their handlers • Unmask the events (allow them to happen.

Event Queues • most systems enqueue events before dispatching • a queue may be

Event Queues • most systems enqueue events before dispatching • a queue may be a simple fifo but more likely a priority queue, that way some events can be dispatched before others

GUI Events • • Keyboard Events Mouse Events Screen Events (touch screens) Pen Events

GUI Events • • Keyboard Events Mouse Events Screen Events (touch screens) Pen Events

Cross Platform GUI Toolkits • Tcl/Tk – The Tk GUI toolkit – Tkinter: python

Cross Platform GUI Toolkits • Tcl/Tk – The Tk GUI toolkit – Tkinter: python wrappers for Tk; open source • GTK+ (Gimp Toolkit) – Py. GTK : Python wrappers for the GTK+; open source • wx. Widgets – wx. Python: Python bindings for wx. Widgets; open source • Qt – Py. Qt: Python bindings for Qt; Py. Qt is a licensed product (as is Qt)

Tkinter : Tk Interface a Python binding to the Tk GUI toolkit de-facto GUI

Tkinter : Tk Interface a Python binding to the Tk GUI toolkit de-facto GUI standard for Python written by Fredrik Lundh Python wrapper around a Tcl interpreter embedded in the Python interpretor; this lets you mix Python and Tcl in the same program. • “themed Tk” - Tk widgets can be themed to look like the hosting OS. • •

Toolkit Relationships

Toolkit Relationships

Previous Slide • The previous slide shows the relationships on UNIX and LINUX systems

Previous Slide • The previous slide shows the relationships on UNIX and LINUX systems where the toolkits are based on X 11, remember X 11 is a clientserver display system where the app is an Xclient and makes calls to xlib to send commands to an display things and uses an xserver to display them. This is very different than the way it is done on Windows

X 11 Architecture Example deployment of X server: the X server receives input from

X 11 Architecture Example deployment of X server: the X server receives input from a local keyboard and mouse and displays to a screen. A web browser and a terminal emulator run on the user's workstation and a software update application runs on a remote computer but is controlled and monitored from the user's machine