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
| from tkinter import *
from math import*
elements=['H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn','Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Cn','Nh']
def curseur(event):
x,y=event.x,event.y
position.configure(text = "position en X =" + str(event.x) +", Y =" + str(event.y))
test=Tk()
test.geometry('1000x800')
test.bind("<Motion>", curseur)
position=Label(test)
position.pack()
for i in range(len(elements)):
if i in range(1): #H
posx=213+i*30+2
posy=(500)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',command=lambda:print(str(posx)+','+str(posy)),width=2)
E.place(x = posx,y = posy)
if i in range(1,2): #He
posx=725
posy=(500)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',command=lambda:print(str(posx)+','+str(posy)),width=2)
E.place(x = posx,y = posy)
if i in range(2,4): #Li, Be
posx=213+(i-2)*30+2
posy=(500+35)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',command=lambda:print(str(posx)+','+str(posy)),width=2)
E.place(x = posx,y = posy)
if i in range(4,10): #B à Ne
posx=213+(i-2)*30+2+300
posy=(500+35)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(10,12): #Na, Mg
posx=213+(i-10)*30+2
posy=(500+70)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(12,18): #Al, Ar
posx=213+(i-12)*30+2+360
posy=(500+70)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(18,36): #K à Kr
posx=213+(i-18)*30+2
posy=(500+105)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(36,54): #Rb à Xe
posx=213+(i-36)*30+2
posy=(500+140)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(54,72): #Cs à Rn
posx=213+(i-54)*30+2
posy=(500+175)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
if i in range(72,len(elements)): #Cs à Rn
posx=213+(i-72)*30+2
posy=(500+210)
E=Button(test,text=elements[i],font='ArialBlack 12 bold',width=2)
E.place(x = posx,y = posy)
test.mainloop() |
Partager