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
|
open('atome','w').write("début, OH ,hydroxide,début, Cl ,chlorure,\
fin, Zn , de Zinc,fin, Mg , de magnésium,fin, H , d'hydrogène,fin, O , d'oxygène ,fin, S , de soufre,,,,")
#fait pour au maximum 2 membres et attention aux espace
def un(event=None):
nom1,nom2='',''
a=str(e1.get())
b=-3
c=open('atome','r').read().split(",")
while b<( len(c)/2 )+10:
b=b+3
try:
a.index(c[b+1])
if c[b]=='début':
nom1=c[b+2]
if c[b]=='fin':
nom2=c[b+2]
except:
None
l1.configure(text=nom1+nom2)
#############################################################""""
from Tkinter import *
f1=Tk()
e1=Entry(f1,bg='white')
e1.grid(row=0,column=1)
Label(text="""entrez le nom abregé de l'atome(ex ' H Cl ' atention aux espaces et aux majuscules)""").grid(row=0,column=0)
Label(text="""voila ce que ça donne==>""").grid(row=1,column=1)
l1=Label(f1,text='')
l1.grid(row=1,column=2)
b1=Button(f1,bg='white',text='éssayer',command=un)
b1.grid(row=2,column=1)
b1=Button(f1,bg='red',text='quitter',command=f1.destroy)
b1.grid(row=10,column=0,sticky=E) |