Commit 57c7bed5 authored by Matheus Müller's avatar Matheus Müller

Selecao de elementos do modo multicamada por PTE ou entrada

parent a0bb7f95
......@@ -41,7 +41,7 @@ def elem_select(i, button):
Labentrys[5].configure(text = 'Max Depht - %f' %Edict[i]['profundidademax'])
for i in arange(6,12):
Labentrys[i].delete (0, len(Labentrys[i].get()))
Labentrys[i].delete (0, "end")
Labentrys[6].insert(0, Edict[int(Econtrol)]['name'])
Labentrys[7].insert(0, Edict[int(Econtrol)]['mass'])
......@@ -264,11 +264,15 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar):
BUpdateD['state']='disabled'
RS['state']='disabled'
RL['state']='disabled'
OFlabentries[9]['state']='disabled'
OFlabentries[10]['state']='disabled'
elif str(distvar.get()) == 'drawing':
BLayer['state']='disabled'
BUpdateD['state']='normal'
RS['state']='normal'
RL['state']='normal'
OFlabentries[9]['state']='normal'
OFlabentries[10]['state']='normal'
def call_layers():
layers()
......
No preview for this file type
......@@ -7,32 +7,136 @@ from PTE import *
Frms = list()
Ldict = list()
Laycount = 0
currdepht = 0
##############################################################################
##############################################################################
# Common Functions
def Dminchange(layernum):
number = float(Ldict[layernum]['LandE'][6].get())
Ldict[layernum]['Dmin'] = number
if layernum > 0:
Ldict[layernum-1]['Dmax'] = number
Ldict[layernum-1]['LandE'][7].delete(0, 'end')
Ldict[layernum-1]['LandE'][7].insert(0, number)
def Dmaxchange(layernum):
number = float(Ldict[layernum]['LandE'][7].get())
Ldict[layernum]['Dmax'] = number
if layernum < len(Ldict):
Ldict[layernum+1]['Dmin'] = number
Ldict[layernum+1]['LandE'][6].delete(0, 'end')
Ldict[layernum+1]['LandE'][6].insert(0, number)
class Layer:
global Ldict
##############################################################################
##############################################################################
def self_destruct():
return 0
class Layer:
def elem_select(i):
return 0
def self_destruct(self): # nao funciona
for n in range(len(self.Elements)):
del self.Elements[n]
del self.Ebuttons[n]
del self.Spinboxes[n]
#for n in range(8):
# del self.Frames[n]
for n in range(2):
del self.Buttons[n]
for n in range(4):
del self.LandE[n]
del self.LabelFrm
def elem_select(self, i):
Frames=list()
Labentrys=list()
def elem_callback(x, edict , ebutton, Labentrys):
PTable(edict[x-1] , ebutton[x-1], Labentrys)
def update(k, Elelist):
Elelist[k]['name'] = str(Labentrys[6].get())
Labentrys[0].configure(text = '%s' %Elelist[k]['name'])
Elelist[k]['mass'] = float(Labentrys[7].get())
Labentrys[1].configure(text = 'Mass - %f' %Elelist[k]['mass'])
Elelist[k]['Z'] = float(Labentrys[8].get())
Labentrys[2].configure(text = 'Z - %f' %Elelist[k]['Z'])
Elelist[k]['symbol'] = str(Labentrys[9].get())
Labentrys[3].configure(text = 'Symbol - %s' %Elelist[k]['symbol'])
Elelist[k]['LineShape'] = float(Labentrys[10].get())
Labentrys[4].configure(text = 'Line Shape α - %f' %Elelist[k]['LineShape'])
tempw=tk.Tk()
tempw.title(self.Elements[i]['name'])
for n in range(3):
Frames.insert(n, tk.Frame(tempw) )
Frames[0].pack(side='left')
Frames[1].pack(side='top')
Frames[2].pack(side='right')
for n in arange(3, 5):
Frames.insert(n, tk.Frame(Frames[0]) )
Frames[3].pack(side='left')
Frames[4].pack(side='right')
# Label // Entries numbers:
# 0 // 6 = Name
# 1 // 7 = Mass
# 2 // 8 = Z (Atomic number)
# 3 // 9 = Symbol
# 4 // 10 = Line shape
# 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(1, tk.Label(Frames[3], width=23, pady=2, text='Mass - %f' %self.Elements[self.Ecount-1]['mass']) )
Labentrys.insert(2, tk.Label(Frames[3], width=23, pady=2, text='Z - %f' %self.Elements[self.Ecount-1]['Z']) )
Labentrys.insert(3, tk.Label(Frames[3], width=23, pady=2, text= 'Symbol - %s' %self.Elements[self.Ecount-1]['symbol']) )
Labentrys.insert(4, tk.Label(Frames[3], width=23, pady=2, text='Line Shape α - %f' %self.Elements[self.Ecount-1]['LineShape']) )
Labentrys.insert(5, tk.Label(Frames[3]) )
for n in range(5):
Labentrys[n].pack()
for n in arange(6, 11):
Labentrys.insert(n, tk.Entry(Frames[4], width=17) )
Labentrys[n].pack()
Labentrys[6].insert(0, self.Elements[i]['name'])
Labentrys[7].insert(0, self.Elements[i]['mass'])
Labentrys[8].insert(0, self.Elements[i]['Z'])
Labentrys[9].insert(0, self.Elements[i]['symbol'])
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.pack()
BUpdate = tk.Button(Frames[1], text ='Update properties', command=lambda i=int(self.Ecount) :update(self.Ecount, self.Elements), width=15)
BUpdate.pack()
tempw.mainloop()
def addel(self):
i = int(self.Ecount)
self.Elements[i]=dict(name="New",symbol="Hf",mass=178.,Z=72,LineShape=200.,profundidademax=10.)
self.Ebuttons.insert(i, tk.Button(self.Frames[6], text=i, command = lambda i=i : elem_select(i) ))
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[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[i].grid(column=0, row=i)
self.Ecount = self.Ecount + 1
def rmvel(self):
return 0
if self.Ecount > 1:
self.Ecount = self.Ecount - 1
del self.Elements[self.Ecount]
self.Ebuttons[self.Ecount].destroy()
del self.Ebuttons[self.Ecount]
self.Spinboxes[self.Ecount].destroy()
del self.Spinboxes[self.Ecount]
def __init__(self, canvas, count):
global Ldict, currdepht
self.Number=count
self.Ecount=0
self.Elements=dict()
......@@ -41,6 +145,8 @@ class Layer:
self.Frames=list()
self.LandE=list()
self.Buttons=list()
self.Dmin=currdepht
self.Dmax=currdepht+1.
self.LabelFrm = tk.LabelFrame(canvas, text = 'Layer %d' %int(Laycount+1), relief='raised', bd=2)
self.LabelFrm.grid(column=(Laycount%4), row=int(math.floor(Laycount/4)) )
......@@ -64,11 +170,15 @@ class Layer:
self.LandE.insert(0, tk.Label(self.Frames[4], width=14, pady=2, text='dƐ/dx') )
self.LandE.insert(1, tk.Label(self.Frames[4], width=14, pady=2, text='dω²/dx') )
self.LandE.insert(2, tk.Label(self.Frames[4], width=14, pady=2, text='Depht min(nm)') )
self.LandE.insert(3, tk.Label(self.Frames[4], width=14, pady=2, text='Depht max(nm)') )
for i in arange(2,4):
for i in arange(4,6):
self.LandE.insert(i, tk.Entry(self.Frames[5], width=11) )
self.LandE.insert(6, tk.Entry(self.Frames[5], width=11, ))
self.LandE.insert(7, tk.Entry(self.Frames[5], width=11, ))
for i in range(4):
for i in range(8):
self.LandE[i].pack()
self.Buttons.insert(0, tk.Button(self.Frames[4], command=lambda i=i :Ldict[self.Number].addel(), text='Add element',width=11))
......@@ -76,20 +186,28 @@ class Layer:
for i in range(2):
self.Buttons[i].pack()
self.LandE[4].insert(0, 200.)
self.LandE[5].insert(0, 20000.)
self.LandE[6].insert(0, self.Dmin)
self.LandE[7].insert(0, self.Dmax)
currdepht = currdepht + 1.
##############################################################################
##############################################################################
def addlay(Laycanvas):
global Laycount, Ldict
Ldict.insert(Laycount, Layer(Laycanvas, Laycount))
Ldict[Laycount].addel()
Laycount = Laycount + 1
##############################################################################
def rmvlay():
global Laycount, Ldict
if Laycount > 0:
Ldict[Laycount].self_destruct()
if Laycount > 1:
Ldict[Laycount-1].self_destruct()
Laycount = Laycount - 1
##############################################################################
......@@ -101,8 +219,8 @@ def layers():
laywin = tk.Tk()
laywin.title('Layers')
laywin.minsize(400,400)
laywin.geometry('400x400+200+400')
laywin.minsize(950,200)
laywin.geometry('950x200+200+600')
for i in range(2):
Frms.insert(i, tk.Frame(laywin))
......@@ -110,13 +228,21 @@ def layers():
Frms[0].pack(side='top')
Frms[1].pack(side='bottom')
Laycanvas = tk.Canvas(Frms[1])
Laycanvas.pack(fill='both',expand=0)
Laycanvas.pack(fill='both',expand='yes')
#Laycanvas.config(scrollregion=(0,0,300, 1000))
#ScrollbarY = tk.Scrollbar(Laycanvas, orient='vertical')
#ScrollbarY.pack( side = 'right', fill='y' )
#ScrollbarY.config(command = Laycanvas.yview)
#Laycanvas.config(yscrollcommand = ScrollbarY.set)
butadd = tk.Button(Frms[0], command=lambda i=i :addlay(Laycanvas), text='Add layer', bd=1, height=1,width=10, pady='4')
butadd.pack(side='left')
butrmv = tk.Button(Frms[0], command=lambda i=i :rmvlay, text='Remove layer', bd=1, height=1,width=10, pady='4')
butrmv = tk.Button(Frms[0], command=lambda i=i :rmvlay(), text='Remove layer', bd=1, height=1,width=10, pady='4')
butrmv.pack(side='left')
butadd.invoke()
laywin.mainloop()
##############################################################################
......
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