1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# -*- coding:utf8 -*-
from Tkinter import *
import time
liste_entry = [] # stockage des entry
index=0
import time
def maj():
heure.set(time.strftime('%H:%M:%S'))
root.after(1000, maj)
def recuperer():
#Récupèrer les valeurs des entry
try:
print map(int, [i.get() for i in liste_entry])
except ValueError:
raise ValueError("Donnée manquante")
def reset():
# effacement des valeurs des entry
for ent in liste_entry:
ent.delete(0, END)
root = Tk()
root.title("ICP") # Titre de la fenetre
i=3
#generation du formulaire
for i in xrange(4):
T=["arg1","arg2","arg3","arg4"]
u = T[index]
texte = "Donnée {}".format(u)
index=index+1
if i < 4:
Label(root, text=texte).grid(row=i+3, column=0)
ent = Entry(root)
ent.grid(row=i+3, column=1)
liste_entry.append(ent)
else:
Label(root, text=texte).grid(row=i+3 - 4, sticky=E)
ent = Entry(root)
ent.grid(row=i+3 - 4, sticky=E)
liste_entry.append(ent)
tex1 = Label(root, text='Interface choix prog !', fg='red').grid(row=1, column=1)
tex2 = Label(root, text='Choix du programme', fg='green').grid(row=7, column=1)
var=IntVar()
Radiobutton(root, text="PROG1", width=15,variable=var,value=1).grid(row=8, column=0)
Radiobutton(root, text="PROG2", width=15,variable=var,value=2).grid(row=8, column=1)
Radiobutton(root, text="PROG3", width=15,variable=var,value=3).grid(row=8, column=2)
Radiobutton(root, text="PROG4", width=15,variable=var,value=4).grid(row=9, column=0)
Radiobutton(root, text="PROG5", width=15,variable=var,value=5).grid(row=9, column=1)
Radiobutton(root, text="PROG6", width=15,variable=var,value=6).grid(row=9, column=2)
Label(root,text=" ").grid(row=10, column=1)
Button(root, text="Ok", width=5, command=recuperer).grid(row=11, column=1)
Button(root, text="reset", width=5, command=reset).grid(row=11, column=0)
Button(root, text="Quit", width=5, command=root.destroy).grid(row=11, column=2)
heure = StringVar()
Label(root,textvariable=heure).grid(row=12, column=1)
maj()
root.mainloop() |
Partager