| Ligne 166 : |
Ligne 166 : |
| | | | |
| | == Et pour finir... == | | == Et pour finir... == |
| − | To start everything going we initialise pygameui, construct the pitft class and then start the potreader thread with a reference to pitft.
| + | Pour démarrer le programme nous initialisons pygameui, construisons la classe pitft class et démarrons le thread potreader avec le pitft en référence. |
| | | | |
| − | Since we're running this extra thread we need a clean way to stop the program. A signal handler is used to trap ctrl+c and terminate the PotReader thread before calling sys.exit - otherwise the program will not close.
| + | Puisque nous exécutons un thread supplémentaire, nous avons également besoin d'une '''méthode propre''' pour terminer le programme. |
| | + | |
| | + | Un gestionnaire de signal (''signal handler'') est utilisé pour capturer ctrl+c et terminer le thread PotReader avant d'appeler sys.exit - sinon le programme ne se fermera pas. |
| | | | |
| | <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| Ligne 176 : |
Ligne 178 : |
| | pitft = PiTft() | | pitft = PiTft() |
| | | | |
| − | # Start the thread running the callable | + | # démarrer le thread exécutant le ''callable'' |
| | potreader = PotReader(pitft) | | potreader = PotReader(pitft) |
| | threading.Thread(target=potreader).start() | | threading.Thread(target=potreader).start() |
| | | | |
| | def signal_handler(signal, frame): | | def signal_handler(signal, frame): |
| − | print 'You pressed Ctrl+C!' | + | print 'Vous avez pressé Ctrl+C!' |
| | potreader.terminate() | | potreader.terminate() |
| | sys.exit(0) | | sys.exit(0) |
| | | | |
| | + | # Enregister le gesionnaire signal_handler pour le lignal SIGINT (interruption) |
| | signal.signal(signal.SIGINT, signal_handler) | | signal.signal(signal.SIGINT, signal_handler) |
| | | | |
| Ligne 191 : |
Ligne 194 : |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | You can run this final example from the pygamelcd project:
| + | == Exécuter == |
| | + | Vous pouvez exécuter cet exemple final depuis le projet pygamelcd: |
| | | | |
| | <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| | sudo python test5.py | | sudo python test5.py |
| | </syntaxhighlight> | | </syntaxhighlight> |
| − |
| |
| | | | |
| | | | |
| | {{RASP-PYGAME-GUI-TRAILER}} | | {{RASP-PYGAME-GUI-TRAILER}} |