lundi 29 décembre 2014

video introduction TKINTER (Python)



Une petite vidéo pour présenter très brièvement TKINTER avec Python


voici le script du dernier exemple

# On importe Tkinter
from tkinter import *
# fonction hello affiche un message
def hello():
    print ('tu as cliqué sur hello!')
def case1():
    print ('tu as coché la case')   
# On crée une fenêtre. Je l'appelle racine car c'est la racine de l'interface que je vais programmer
racine = Tk()
# un label est une ligne de texte , On affecte le label à la fenêtre racine
retour1=IntVar() # creation de variable-retour
champ_label = Label(racine, text="Bonjour Blerow !")
# le pack permet d'associer le widget à l'environnement
champ_label.pack()
#creation d'un label qui utilise la commande hello()
champ_label2 = Label(racine, text='helloooo')
# le pack permet d'associer le widget à l'environnement
champ_label2.pack()


boutonquit= Button(racine, text='QUITTER', command=racine.destroy)
# le pack permet d'associer le widget à l'environnement
boutonquit.pack(side=LEFT)

b1 = Button(racine, text='hello', command=hello)
b1.pack(side=RIGHT)


case=Checkbutton(racine, variable=retour1, text="Case 1", command=case1)
case.pack()

# On affiche la fenêtre racine via une boucle
racine.mainloop()

Aucun commentaire:

Enregistrer un commentaire