Ligne 1 : |
Ligne 1 : |
| {{RASP-PYGAME-GUI-NAV}} | | {{RASP-PYGAME-GUI-NAV}} |
− |
| |
− | {{traduction}}
| |
| | | |
| == Entrée Analogique == | | == Entrée Analogique == |
Ligne 110 : |
Ligne 108 : |
| | | |
| == Définition de l'interface utilisateur == | | == Définition de l'interface utilisateur == |
− | We've added a couple more widgets to the scene now and resized the buttons to accommodate them. We're showing the voltage on a label and a progress widget. The {{fname|set_progress}} and {{fname|set_volts_label}} methods are called from the PotReader thread to update the values in these widgets.
| + | Nous avons ajouté quelques widget supplémentaires sur la Scene et modifié la taille des boutons (pour que tout se présente correctement). |
| + | |
| + | Nous allons afficher la tension sur un widget label (''libellé'') et un widget progress (''barre de progression''). |
| + | |
| + | Les méthodes {{fname|set_progress}} et {{fname|set_volts_label}} sont appelées depuis le thread PotReader pour faire la mise-à-jour des valeurs dans ces Widgets. |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
Ligne 162 : |
Ligne 164 : |
| | | |
| == 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 172 : |
Ligne 176 : |
| 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 187 : |
Ligne 192 : |
| </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}} |