# -*- coding: iso-8859-15 -*- import Tkinter as tk from Elements import * from numpy import * from pylab import * from spectro import * ####################################### # Initial parameters param = dict(dedx=287. ,Theta_out=70., dW2dx=35000., E0= 100000., Theta_in=0., FWHM0=300.) ionb = dict(Z=1, mass=1.0079) ####################################### # Calculation callback # Defines parameters def init_calc(): param['dedx'] = float(Entrydedx.get()) param['dW2dx'] = float(EntrydW2dx.get()) param['Theta_out'] = float(EntryT_out.get()) param['Theta_in'] = float(EntryT_in.get()) param['E0'] = float(EntryE0.get()) param['FWHM0'] = float(EntryFWHM0.get()) ionb['mass'] = float(Entryionmass.get()) ionb['Z'] = float(EntryionZ.get()) data=spectro_espalhamento(float(EntryEmin.get()),float(EntryEmax.get()),20) #data.addelements2(['profHf.dat','profO.dat'],param,0.9,'gaussiana',0.01) data.sweepelements(param, 'gaussiana', ionb) data.plot() ####################################### # Main window root = tk.Tk() root.minsize(385,355) root.title('Open Flatus') Label1 = tk.Label(root, text = 'Elements', relief='raised', bd=2) Label1.grid(column=0, row=9) Label2 = tk.Label(root, text = 'Parameters', relief='raised', bd=2) Label2.grid(column=0, row=0) Label3 = tk.Label(root, text = 'Ion parameters', relief='raised', bd=2) Label3.grid(column=0, row=2) CalcButton = tk.Button(root, text = 'Calculate', command = init_calc, bd=4, width=20, height=4) CalcButton.grid(column=10, row=10) ####################################### # Frames Eframe = tk.Frame(root) Eframe.grid(column=0, row=10) Pframel = tk.Frame(root) Pframel.grid(column=0, row=1, sticky='w') Pframee = tk.Frame(root) Pframee.grid(column=0, row=1, sticky='e') Iframel = tk.Frame(root, width=8) Iframel.grid(column=0, row=3, sticky='w') Iframee = tk.Frame(root, width=12) Iframee.grid(column=0, row=3, sticky='e') ####################################### # Elements callback elemw(Eframe) ####################################### # Parameters # Labels Labeldedx = tk.Label(Pframel, width=8, text='dƐ/dx') LabeldW2dx = tk.Label(Pframel, width=8, text='dω²/dx') LabelT_out = tk.Label(Pframel, width=8, text='θ out') LabelT_in = tk.Label(Pframel, width=8, text='θ in') LabelE0 = tk.Label(Pframel, width=8, text='E0') LabelFWHM0 = tk.Label(Pframel, width=8, text='FWHM0') LabelEmin = tk.Label(Pframel, width=8, text='Emin') LabelEmax = tk.Label(Pframel, width=8, text='Emax') Labeldedx.pack() LabeldW2dx.pack() LabelT_out.pack() LabelT_in.pack() LabelE0.pack() LabelFWHM0.pack() LabelEmin.pack() LabelEmax.pack() # Entries Entrydedx = tk.Entry(Pframee, width=12) EntrydW2dx = tk.Entry(Pframee, width=12) EntryT_out = tk.Entry(Pframee, width=12) EntryT_in = tk.Entry(Pframee, width=12) EntryE0 = tk.Entry(Pframee, width=12) EntryFWHM0 = tk.Entry(Pframee, width=12) EntryEmin = tk.Entry(Pframee, width=12) EntryEmax = tk.Entry(Pframee, width=12) Entrydedx.pack() EntrydW2dx.pack() EntryT_out.pack() EntryT_in.pack() EntryE0.pack() EntryFWHM0.pack() EntryEmin.pack() EntryEmax.pack() #Ion Labelionmass = tk.Label(Iframel, width=8, text='Mass') LabelionZ = tk.Label(Iframel, width=8, text='Z') Labelionmass.pack() LabelionZ.pack() Entryionmass = tk.Entry(Iframee, width=12) EntryionZ = tk.Entry(Iframee, width=12) Entryionmass.pack() EntryionZ.pack() #Initial values Entrydedx.insert(0,param['dedx']) EntrydW2dx.insert(0,param['dW2dx']) EntryT_out.insert(0,param['Theta_out']) EntryT_in.insert(0,param['Theta_in']) EntryE0.insert(0,param['E0']) EntryFWHM0.insert(0,param['FWHM0']) EntryEmin.insert(0,50000) EntryEmax.insert(0,100000) Entryionmass.insert(0, ionb['mass']) EntryionZ.insert(0, ionb['Z']) ####################################### root.mainloop() #######################################