|
META TOPICPARENT |
name="WorkshopSlides" |
Slide 1: Introduction to Internet of Things (IoT) |
|
We can therefore find out if the module is imported or executed by checking the name variable: |
|
< < | _if name_ == "__main__" |
> > | if _name_ == "__main__" |
|
this executes the main code only if not imported into a main program
|
|
A very typical example of a python library is matplotlib for plotting. |
|
< < | |
> > | |
| |
|
< < | |
> > | |
|
Callbacks |
|
< < | |
> > | Callbacks are very often used in Graphical User Interface (GUI systems)
GUI elements (widgets) are set up by the programmer and events are attached to them.
Typical examples are:
- Selection of an intem in a list
- Selection on a menu item
- pushing a push button
- checking a check box
The GUI systems runs in an endless loop and calls pre-registered functions
(the callback functions) when any of the above events happens. The event is then
acted upon and control is returned to the GUI main loop.
A Dummy GUI
Our dummy GUI allows to register a callback and if one is registered it will call it every 2 s.
The application running the dummy GUI
The application first registers the callback and then gives control to the dummy GUI main loop.
The main loop will wait for an event (2 s elapsed) and call the callback function when
the event has occurred.
|
|
%SLIDESHOWEND% |
|
META FILEATTACHMENT |
attachment="plotgraph.png" attr="" comment="" date="1560396031" name="plotgraph.png" path="plotgraph.png" size="180708" user="IsaacArmahMensah" version="1" |
META FILEATTACHMENT |
attachment="variables.png" attr="" comment="" date="1560396299" name="variables.png" path="variables.png" size="206780" user="IsaacArmahMensah" version="1" |
META FILEATTACHMENT |
attachment="plot1.png" attr="" comment="" date="1560396703" name="plot1.png" path="plot1.png" size="102039" user="IsaacArmahMensah" version="1" |
|
|
> > |
META FILEATTACHMENT |
attachment="mathplotlib.png" attr="" comment="" date="1560513874" name="mathplotlib.png" path="mathplotlib.png" size="89453" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="mathplotlibCode.png" attr="" comment="" date="1560513877" name="mathplotlibCode.png" path="mathplotlibCode.png" size="30671" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="callbackReg.png" attr="" comment="" date="1560514438" name="callbackReg.png" path="callbackReg.png" size="16057" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="dummyGUI.png" attr="" comment="" date="1560514439" name="dummyGUI.png" path="dummyGUI.png" size="33352" user="UliRaich" version="1" |
|