Tkinter : Boutons, labels .....
Créer des boutons, des labels, des champs de saisie sous Tkinter... Les outils d’un petit logiciel....
Article mis en ligne le 24 octobre 2014
dernière modification le 11 juin 2016
Création d’une fenêtre Tkinter :
On va commencer par créer une fenêtre dans laquelle nous positionnerons nos objets.
Une vidéo pour expliquer cela :
<iframe
class="player"
type="text/html"
width="600"
height="480"
src="http://www.youtube.com/embed/rTCiK_KskeA?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=1"
frameborder="0"
allowfullscreen
webkitallowfullscreen
mozallowfullscreen
>
Le code :
++++
Créer un bouton :
<iframe
class="player"
type="text/html"
width="600"
height="480"
src="http://www.youtube.com/embed/TuC4kdkdsio?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=1"
frameborder="0"
allowfullscreen
webkitallowfullscreen
mozallowfullscreen
>
Le code :
++++
Créer un label (une étiquette) :
<iframe
class="player"
type="text/html"
width="600"
height="480"
src="http://www.youtube.com/embed/S_U4bvtBy3U?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=1"
frameborder="0"
allowfullscreen
webkitallowfullscreen
mozallowfullscreen
>
Le code :
++++
Créer un champ de saisie :
<iframe
class="player"
type="text/html"
width="600"
height="480"
src="http://www.youtube.com/embed/fvbmHgivo2k?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=1"
frameborder="0"
allowfullscreen
webkitallowfullscreen
mozallowfullscreen
>
Le code :
Fin du programme, récupérer les valeurs saisies :
<iframe
class="player"
type="text/html"
width="600"
height="480"
src="http://www.youtube.com/embed/YLKe0234ZRQ?enablejsapi=1&wmode=transparent&modestbranding=1&rel=0&fs=1&showinfo=1"
frameborder="0"
allowfullscreen
webkitallowfullscreen
mozallowfullscreen
>
Le code final :
++++
Un autre exemple avec des nombres aléatoires :
Lancer d’un dé :
Voici une deuxième application pour simuler le lancer d’un dé.
! Missions !
- Level 1 :
Complétez la dernière application pour faire lancer deux dés simiultanément.
Afficher la somme des deux dés...
- Level 2 :
Créez votre calculatrice
- Level 3 :
Créez votre application pour tester ses tables de multiplications