18 myDC= TestEm0.DetectorConstruction()
19 g4.gRunManager.SetUserInitialization(myDC)
21 myPL= TestEm0.PhysicsList()
22 g4.gRunManager.SetUserInitialization(myPL)
25 myPGA= TestEm0.PrimaryGeneratorAction(myDC)
26 g4.gRunManager.SetUserAction(myPGA)
28 myRA= TestEm0.RunAction(myDC,myPGA)
31 g4.gRunManager.SetUserAction(myRA)
35 g4.gRunManager.Initialize()
37 pg = g4.G4ParticleGun()
39 materialList = TestEm0.getMaterialTable();
41 particleList = TestEm0.getParticleTable()
43 enrgyList = [
"eV",
"keV",
"MeV",
"GeV",
"TeV",
"PeV"]
45 cutsList = [
"um",
"mm" ,
"cm",
"m",
"km"]
59 title = Label(self, text=
"TestEm0 empowered by Geant4Py\n\n\n")
60 title.grid(row=0, column=1, columnspan = 4)
63 particle_title = Label(self, text=
"Particle")
64 particle_title.grid(row=2, column=0)
66 particleFrame = Frame(self)
67 scrollbar2 = Scrollbar(particleFrame)
68 scrollbar2.pack(side = RIGHT, fill = Y)
69 self.
particleListBox = Listbox(particleFrame, yscrollcommand=scrollbar2.set, exportselection=FALSE,height = 6)
70 self.particleListBox.pack(side = LEFT)
71 for item
in particleList:
72 self.particleListBox.insert(END, item)
73 scrollbar2.config(command=self.particleListBox.yview)
74 particleFrame.grid(row=3, column=0)
75 self.particleListBox.select_set(0)
78 fblank = Frame(self,width = 40)
79 fblank.grid(row=3,column=1)
82 detmaterial_title = Label(self, text=
"Material")
83 detmaterial_title.grid(row=2, column=2)
85 materialFrame = Frame(self)
86 scrollbar = Scrollbar(materialFrame)
87 scrollbar.pack(side = RIGHT, fill = Y)
88 self.
materialListBox = Listbox(materialFrame, yscrollcommand=scrollbar.set, exportselection=FALSE, height = 6)
89 self.materialListBox.pack(side = LEFT, fill = Y)
90 for item
in materialList:
91 self.materialListBox.insert(END, item)
92 scrollbar.config(command=self.materialListBox.yview)
93 materialFrame.grid(row=3, column=2)
94 self.materialListBox.select_set(0)
97 fblank = Frame(self,width = 40)
98 fblank.grid(row=3,column=3)
101 fEnergy = Frame(self)
102 energyLabel = Label(self, text=
"Energy")
103 energyLabel.grid(row = 2, column = 4)
105 scrollbarEnergy = Scrollbar(fEnergy)
106 scrollbarEnergy.pack(side = RIGHT, fill = Y)
108 self.energyEntry.pack(side = TOP)
109 self.energyEntry.insert(0,
"1.0")
111 self.
energyListBox = Listbox(fEnergy, yscrollcommand=scrollbarEnergy.set,exportselection=FALSE,width=8,height = 5)
112 self.energyListBox.pack(side = BOTTOM )
113 for item
in enrgyList:
114 self.energyListBox.insert(END, item)
115 scrollbarEnergy.config(command=self.energyListBox.yview)
116 fEnergy.grid(row = 3, column = 4 )
117 self.energyListBox.select_set(0)
120 fblank = Frame(self,width = 40)
121 fblank.grid(row=3,column=5)
125 cutsLabel = Label(self, text=
"Cuts", width= 8)
126 cutsLabel.grid(row = 2, column = 6)
128 scrollbarCuts = Scrollbar(fCuts)
129 scrollbarCuts.pack(side = RIGHT, fill = Y)
131 self.cutsEntry.pack(side = TOP)
132 self.cutsEntry.insert(0,
"1.0")
134 self.
cutsListBox = Listbox(fCuts, width= 8 ,yscrollcommand=scrollbarCuts.set,exportselection=FALSE,height = 5)
135 self.cutsListBox.pack(side = BOTTOM )
136 for item
in cutsList:
137 self.cutsListBox.insert(END, item)
138 scrollbarCuts.config(command=self.cutsListBox.yview)
139 fCuts.grid(row = 3, column = 6 )
140 self.cutsListBox.select_set(0)
143 fblank = Frame(self,height = 40)
144 fblank.grid(row=4,column=0)
147 startBut = Button(self, bg=
"green", text=
"Start a run", command=self.
cmd_beamOn)
148 startBut.grid(row=5, column=2, sticky=W)
151 exitBut = Button(self, bg=
"grey", text=
"Exit", command=self.quit)
152 exitBut.grid(row=5, column=6, sticky=E)
155 Frame.__init__(self, master)
162 if self.particleListBox.curselection():
163 index =
int(self.particleListBox.curselection()[0])
164 g4.gApplyUICommand(
"/gun/particle " + particleList[index])
167 if self.materialListBox.curselection():
168 index =
int(self.materialListBox.curselection()[0])
169 g4.gApplyUICommand(
"/testem/det/setMat " + materialList[index])
172 energy = self.energyEntry.get()
173 if self.energyListBox.curselection():
174 index =
int(self.energyListBox.curselection()[0])
175 unity = enrgyList[index]
176 g4.gApplyUICommand(
"/gun/energy " + energy +
" " + unity)
179 cuts = self.cutsEntry.get()
180 if self.cutsListBox.curselection():
181 index =
int(self.cutsListBox.curselection()[0])
182 unity = cutsList[index]
183 g4.gApplyUICommand(
"/testem/phys/setCuts " + cuts +
" " + unity)
186 g4.gRunManager.BeamOn(1)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)