OpenFlatus.py 5.41 KB
Newer Older
1 2 3
# -*- coding: iso-8859-15 -*-

import Tkinter as tk
4
from Ewindow import *
5
from numerical import *
6
import sys
7

8
##############################################################################
9
# Initial parameters
10
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.)
11 12
ionb = dict(Z=1, mass=1.0079)

13
##############################################################################
14 15 16 17
# Calculation callback
# Defines parameters

def init_calc():
18
    global modelvar
19 20 21 22 23
    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())
24
    param['FWHM0'] = float(EntryFWHM0.get())
25
    ionb['mass'] = float(Entryionmass.get())
26
    ionb['Z'] = float(EntryionZ.get())      
27

28
    spectro(param, str(modelvar.get()), ionb, float(EntryEmin.get()),float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()) )
29

30
##############################################################################
31 32 33
# Main window

root = tk.Tk()
34
root.minsize(730,460)
35
root.title('Open Flatus')
36
root.geometry('375x270+200+400')
37

38
##############################################################################
39 40 41
# Frames
MasterFrame1 = tk.Frame(root)
MasterFrame1.pack(side='left')
42 43
MasterFrame2 = tk.Frame(root)
MasterFrame2.pack(side='top')
44 45 46 47

Label2 = tk.LabelFrame(MasterFrame1, text = 'Parameters', relief='raised', bd=2)
Label2.pack(side='top')
Label3 = tk.LabelFrame(MasterFrame1, text = 'Ion parameters', relief='raised', bd=2)
48 49 50 51 52 53 54
Label3.pack(side='top')
Label4 = tk.LabelFrame(MasterFrame1, text = 'Energy loss model', relief='raised', bd=2)
Label4.pack(side='top')

# Elements frame
Label1 = tk.Frame(MasterFrame2)
Label1.pack(side='top')
55 56 57 58 59 60

Pframel = tk.Frame(Label2)
Pframel.pack(side='left')
Pframee = tk.Frame(Label2)
Pframee.pack(side='right')

61
Iframel = tk.Frame(Label3, width=9)
62
Iframel.pack(side='left')
63
Iframee = tk.Frame(Label3, width=11)
64
Iframee.pack(side='right')
65

66
##############################################################################
67 68
# Parameters
# Labels
69 70 71 72
Labeldedx = tk.Label(Pframel, width=9, text='dƐ/dx', pady=2)
LabeldW2dx = tk.Label(Pframel, width=9, text='dω²/dx', pady=2)
LabelT_out = tk.Label(Pframel, width=9, text='θ out', pady=2)
LabelT_in = tk.Label(Pframel, width=9, text='θ in', pady=2)
73
LabelFWHM0 = tk.Label(Pframel, width=9, text='FWHM0')
74 75 76
LabelEmin = tk.Label(Pframel, width=9, text='Emin', pady=2)
LabelEmax = tk.Label(Pframel, width=9, text='Emax', pady=2)
LabelEstep = tk.Label(Pframel, width=9, text='Estep', pady=2)
77
LabelDstep = tk.Label(Pframel, width=9, text='Depth step', pady=2)
78 79 80 81
Labeldedx.pack()
LabeldW2dx.pack()
LabelT_out.pack()
LabelT_in.pack()
82
LabelFWHM0.pack()
83 84
LabelEmin.pack()
LabelEmax.pack()
85 86
LabelEstep.pack()
LabelDstep.pack()
87 88

# Entries
89 90 91 92
Entrydedx = tk.Entry(Pframee, width=11)
EntrydW2dx = tk.Entry(Pframee, width=11)
EntryT_out = tk.Entry(Pframee, width=11)
EntryT_in = tk.Entry(Pframee, width=11)
93
EntryFWHM0 = tk.Entry(Pframee, width=11)
94 95 96 97
EntryEmin = tk.Entry(Pframee, width=11)
EntryEmax = tk.Entry(Pframee, width=11)
EntryEstep = tk.Entry(Pframee, width=11)
EntryDstep = tk.Entry(Pframee, width=11)
98 99 100 101
Entrydedx.pack()
EntrydW2dx.pack()
EntryT_out.pack()
EntryT_in.pack()
102
EntryFWHM0.pack()
103
EntryEmin.pack()
104
EntryEmax.pack()
105 106
EntryEstep.pack()
EntryDstep.pack()
107 108

#Ion
109 110 111 112
LabelE0 = tk.Label(Iframel, width=9, text='Energy')
Labelionmass = tk.Label(Iframel, width=9, text='Mass')
LabelionZ = tk.Label(Iframel, width=9, text='Z')
LabelE0.pack()
113 114
Labelionmass.pack()
LabelionZ.pack()
115 116 117 118
EntryE0 = tk.Entry(Iframee, width=11)
Entryionmass = tk.Entry(Iframee, width=11)
EntryionZ = tk.Entry(Iframee, width=11)
EntryE0.pack()
119 120 121 122 123 124 125 126 127
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'])
128
EntryFWHM0.insert(0,param['FWHM0'])
129
EntryEmin.insert(0,70000)
130
EntryEmax.insert(0,100000) 
131 132
EntryEstep.insert(0,20) 
EntryDstep.insert(0,0.01) 
133 134 135
Entryionmass.insert(0, ionb['mass'])
EntryionZ.insert(0, ionb['Z'])

136
##############################################################################
137 138 139 140 141 142 143
# Energy loss models

modelvar = tk.StringVar()
R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana')
R1.pack()
R2 = tk.Radiobutton(Label4, text="Bessel", variable=modelvar, value='bessel')
R2.pack()
144
R2.select()
145

146 147 148 149 150 151
##############################################################################
# Line shape checkbox

LSvar = tk.IntVar()
C1 = tk.Checkbutton(Label4, text="Use Line Shape", variable=LSvar)
C1.pack()
152
C1.select()
153 154

##############################################################################
155

156
CalcButton = tk.Button(Label4, text = 'Calculate', command = init_calc, bd=4, width=17, height=2)
157 158
CalcButton.pack()

159
ExitButton = tk.Button(Label4, text = 'Exit', command = sys.exit, bd=4, width=17, height=2)
160 161
ExitButton.pack(side='bottom')

162
##############################################################################
163 164
# Elements callback

165
ewin_build(Label1, 15, float(EntryDstep.get()))
166

167
##############################################################################
168

169
spectro(param, 'gaussiana', ionb, float(EntryEmin.get()), float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()) )
170 171

root.mainloop()
172
Label1.mainloop()
173

174
##############################################################################