Commit d1ad2d2e authored by Matheus Müller's avatar Matheus Müller

Remocao de classe Layer e selecao de elementos funcional

parent 57c7bed5
...@@ -29,31 +29,36 @@ def Dmaxchange(layernum): ...@@ -29,31 +29,36 @@ def Dmaxchange(layernum):
Ldict[layernum+1]['LandE'][6].delete(0, 'end') Ldict[layernum+1]['LandE'][6].delete(0, 'end')
Ldict[layernum+1]['LandE'][6].insert(0, number) Ldict[layernum+1]['LandE'][6].insert(0, number)
##############################################################################
def elem_callback(x, edict , ebutton, Labentrys):
PTable(edict[x] , ebutton[x], Labentrys)
############################################################################## ##############################################################################
############################################################################## ##############################################################################
class Layer: class Layer:
def self_destruct(self): # nao funciona def self_destruct(self):
for n in range(len(self.Elements)): for n in range(len(self.Elements)):
del self.Elements[n] del self.Elements[n]
self.Ebuttons[n].grid_forget()
del self.Ebuttons[n] del self.Ebuttons[n]
self.Spinboxes[n].grid_forget()
del self.Spinboxes[n] del self.Spinboxes[n]
#for n in range(8): for n in range(8):
# del self.Frames[n] self.Frames[n].pack_forget()
for n in range(2): for k in arange(0,1):
del self.Buttons[n] self.Buttons[k].pack_forget()
for n in range(4): for j in range(4):
del self.LandE[n] self.LandE[j].pack_forget()
del self.LabelFrm self.LabelFrm.grid_forget()
def elem_select(self, i): def elem_select(self, i):
Frames=list() Frames=list()
Labentrys=list() Labentrys=list()
def elem_callback(x, edict , ebutton, Labentrys):
PTable(edict[x-1] , ebutton[x-1], Labentrys)
def update(k, Elelist): def update(k, Elelist):
Elelist[k]['name'] = str(Labentrys[6].get()) Elelist[k]['name'] = str(Labentrys[6].get())
Labentrys[0].configure(text = '%s' %Elelist[k]['name']) Labentrys[0].configure(text = '%s' %Elelist[k]['name'])
...@@ -89,11 +94,11 @@ class Layer: ...@@ -89,11 +94,11 @@ class Layer:
# 3 // 9 = Symbol # 3 // 9 = Symbol
# 4 // 10 = Line shape # 4 // 10 = Line shape
# 5 // 11 = Max Depht # 5 // 11 = Max Depht
Labentrys.insert(0, tk.Label(Frames[3], width=23, pady=2, text='%s' %self.Elements[self.Ecount-1]['name']) ) Labentrys.insert(0, tk.Label(Frames[3], width=23, pady=2, text='%s' %self.Elements[i]['name']) )
Labentrys.insert(1, tk.Label(Frames[3], width=23, pady=2, text='Mass - %f' %self.Elements[self.Ecount-1]['mass']) ) Labentrys.insert(1, tk.Label(Frames[3], width=23, pady=2, text='Mass - %f' %self.Elements[i]['mass']) )
Labentrys.insert(2, tk.Label(Frames[3], width=23, pady=2, text='Z - %f' %self.Elements[self.Ecount-1]['Z']) ) Labentrys.insert(2, tk.Label(Frames[3], width=23, pady=2, text='Z - %f' %self.Elements[i]['Z']) )
Labentrys.insert(3, tk.Label(Frames[3], width=23, pady=2, text= 'Symbol - %s' %self.Elements[self.Ecount-1]['symbol']) ) Labentrys.insert(3, tk.Label(Frames[3], width=23, pady=2, text= 'Symbol - %s' %self.Elements[i]['symbol']) )
Labentrys.insert(4, tk.Label(Frames[3], width=23, pady=2, text='Line Shape α - %f' %self.Elements[self.Ecount-1]['LineShape']) ) Labentrys.insert(4, tk.Label(Frames[3], width=23, pady=2, text='Line Shape α - %f' %self.Elements[i]['LineShape']) )
Labentrys.insert(5, tk.Label(Frames[3]) ) Labentrys.insert(5, tk.Label(Frames[3]) )
for n in range(5): for n in range(5):
...@@ -109,17 +114,18 @@ class Layer: ...@@ -109,17 +114,18 @@ class Layer:
Labentrys[9].insert(0, self.Elements[i]['symbol']) Labentrys[9].insert(0, self.Elements[i]['symbol'])
Labentrys[10].insert(0, self.Elements[i]['LineShape']) Labentrys[10].insert(0, self.Elements[i]['LineShape'])
butPTE = tk.Button(Frames[1],text='Select from PTE',width=15,command=lambda i=i:elem_callback(self.Ecount,self.Elements,self.Ebuttons,Labentrys)) butPTE = tk.Button(Frames[1],text='Select from PTE',width=15,command=lambda i=i:elem_callback(i,self.Elements,self.Ebuttons,Labentrys))
butPTE.pack() butPTE.pack()
BUpdate = tk.Button(Frames[1], text ='Update properties', command=lambda i=int(self.Ecount) :update(self.Ecount, self.Elements), width=15) BUpdate = tk.Button(Frames[1], text ='Update properties', command=lambda i=i: update(i, self.Elements), width=15)
BUpdate.pack() BUpdate.pack()
tempw.mainloop() tempw.mainloop()
def addel(self): def addel(self):
i = int(self.Ecount) i = int(self.Ecount)
n = int(self.Number)
self.Elements[i]=dict(name="New",symbol="Hf",mass=178.,Z=72,LineShape=200.) self.Elements[i]=dict(name="New",symbol="Hf",mass=178.,Z=72,LineShape=200.)
self.Ebuttons.insert(i, tk.Button(self.Frames[6], text=i, command = lambda i=i : self.elem_select(i) )) self.Ebuttons.insert(i, tk.Button(self.Frames[6], text=i, command = lambda x=0: Ldict[n].elem_select(i) ))
self.Ebuttons[i].grid(column=0, row=i) self.Ebuttons[i].grid(column=0, row=i)
self.Spinboxes.insert(i, tk.Spinbox(self.Frames[7], from_=0, to=1, increment=0.05, bd=5 )) self.Spinboxes.insert(i, tk.Spinbox(self.Frames[7], from_=0, to=1, increment=0.05, bd=5 ))
self.Spinboxes[i].grid(column=0, row=i) self.Spinboxes[i].grid(column=0, row=i)
...@@ -208,6 +214,7 @@ def rmvlay(): ...@@ -208,6 +214,7 @@ def rmvlay():
global Laycount, Ldict global Laycount, Ldict
if Laycount > 1: if Laycount > 1:
Ldict[Laycount-1].self_destruct() Ldict[Laycount-1].self_destruct()
del Ldict[Laycount-1]
Laycount = Laycount - 1 Laycount = Laycount - 1
############################################################################## ##############################################################################
...@@ -219,7 +226,7 @@ def layers(): ...@@ -219,7 +226,7 @@ def layers():
laywin = tk.Tk() laywin = tk.Tk()
laywin.title('Layers') laywin.title('Layers')
laywin.minsize(950,200) laywin.minsize(950,400)
laywin.geometry('950x200+200+600') laywin.geometry('950x200+200+600')
for i in range(2): for i in range(2):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment