Difference: IntroductionToNopIoTAndPython (9 vs. 10)

Revision 102019-06-14 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WorkshopSlides"

Start Presentation

Slide 1: Introduction to Internet of Things (IoT)

Line: 379 to 379
  We can therefore find out if the module is imported or executed by checking the name variable:
Changed:
<
<
_if name_ == "__main__"
>
>
if _name_ == "__main__"
  this executes the main code only if not imported into a main program

Line: 435 to 435
  A very typical example of a python library is matplotlib for plotting.
Changed:
<
<
plot1.png
>
>
mathplotlibCode.png
 
Changed:
<
<
plotgraph.png
>
>
mathplotlib.png
 

Callbacks

Changed:
<
<
callback.png
>
>
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.

dummyGUI.png

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.

callbackReg.png

 
%SLIDESHOWEND%
Line: 483 to 514
 
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"
Added:
>
>
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"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback