Geant4  10.02.p03
emcalc_gui.MainWindow Class Reference
Collaboration diagram for emcalc_gui.MainWindow:

Public Member Functions

def __init__ (self)
 
def create_header (self)
 
def create_particle_frame (self)
 
def create_material_frame (self)
 
def create_action_box (self)
 
def cb_show_textview (self, widget, data=None)
 
def cb_select_particle (self, widget, data=None)
 
def cb_select_material (self, widget, data=None)
 
def cb_show_plot (self, widget, data=None)
 
def cb_close_dialog (self, widget, data=None)
 

Public Attributes

 mainwindow
 
 textview
 
 error_dialog
 
 particle
 
 material_list
 
 material_combo
 
 material
 

Private Attributes

 __margin
 

Detailed Description

Definition at line 122 of file emcalc_gui.py.

Constructor & Destructor Documentation

◆ __init__()

def emcalc_gui.MainWindow.__init__ (   self)

Definition at line 123 of file emcalc_gui.py.

123  def __init__(self) :
124  self.__margin = 8
125 
126  # main window
127  self.mainwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
128  self.mainwindow.set_title('Em Calculator')
129  self.mainwindow.set_position(gtk.WIN_POS_MOUSE)
130  self.mainwindow.set_default_size(500, 300)
131  self.mainwindow.connect('delete-event', lambda w,d: gtk.main_quit())
132  self.mainwindow.connect('destroy-event',lambda w,d: gtk.main_quit())
133 
134  # components
135  header = self.create_header()
136 
137  particle_frame = self.create_particle_frame()
138  particle_frame.set_border_width(self.__margin)
139 
140  material_frame = self.create_material_frame()
141  material_frame.set_border_width(self.__margin)
142 
143  separator = gtk.HSeparator()
144 
145  action_box = self.create_action_box()
146  action_box.set_border_width(self.__margin)
147 
148  # layout
149  vbox = gtk.VBox()
150  vbox.pack_start(header)
151  vbox.pack_start(particle_frame)
152  vbox.pack_start(material_frame)
153  vbox.pack_start(separator)
154  vbox.pack_start(action_box)
155 
156  self.mainwindow.add(vbox)
157  self.mainwindow.show_all()
158 
159  # text view
160  self.textview = TextView()
161 
162  # error dialog
163  self.error_dialog = gtk.MessageDialog(parent=self.mainwindow,
164  buttons=gtk.BUTTONS_CLOSE, type=gtk.MESSAGE_ERROR,
165  message_format="Material is not defined in G4Nist materials")
166  self.error_dialog.connect("response", self.cb_close_dialog)
167 

Member Function Documentation

◆ cb_close_dialog()

def emcalc_gui.MainWindow.cb_close_dialog (   self,
  widget,
  data = None 
)

Definition at line 295 of file emcalc_gui.py.

295  def cb_close_dialog(self, widget, data=None) :
296  widget.hide_all()
297 
298 
299 # -------------------------------------------------------------------
300 # text view
301 # -------------------------------------------------------------------

◆ cb_select_material()

def emcalc_gui.MainWindow.cb_select_material (   self,
  widget,
  data = None 
)

Definition at line 276 of file emcalc_gui.py.

276  def cb_select_material(self, widget, data=None) :
277  entry = widget.get_child()
278  self.material = entry.get_text()
279 

◆ cb_select_particle()

def emcalc_gui.MainWindow.cb_select_particle (   self,
  widget,
  data = None 
)

Definition at line 273 of file emcalc_gui.py.

273  def cb_select_particle(self, widget, data=None) :
274  self.particle = data
275 
Here is the caller graph for this function:

◆ cb_show_plot()

def emcalc_gui.MainWindow.cb_show_plot (   self,
  widget,
  data = None 
)

Definition at line 280 of file emcalc_gui.py.

280  def cb_show_plot(self, widget, data=None) :
281  g4mate = gNistManager.FindOrBuildMaterial(self.material)
282  if (g4mate == None) :
283  self.error_dialog.show_all()
284  return
285 
286  if (self.material_list.count(self.material) == 0) :
287  self.material_combo.append_text(self.material)
288 
289  if (self.particle == "gamma" ) :
290  plot_gamma(self.material)
291  else :
292  plot_charged(self.material, self.particle)
293  self.textview.textbuffer.set_text(mycout.getvalue())
294 
def plot_charged(material, pname)
Definition: emcalc_gui.py:27
def plot_gamma(material)
Definition: emcalc_gui.py:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cb_show_textview()

def emcalc_gui.MainWindow.cb_show_textview (   self,
  widget,
  data = None 
)

Definition at line 269 of file emcalc_gui.py.

269  def cb_show_textview(self, widget, data=None) :
270  window = self.textview.get_window()
271  window.show_all()
272 
Here is the caller graph for this function:

◆ create_action_box()

def emcalc_gui.MainWindow.create_action_box (   self)

Definition at line 250 of file emcalc_gui.py.

250  def create_action_box(self) :
251  box = gtk.HButtonBox()
252  box.set_layout(gtk.BUTTONBOX_END)
253  box.set_spacing(self.__margin)
254 
255  exec_button = gtk.Button(stock = gtk.STOCK_EXECUTE)
256  text_button = gtk.Button("Text View")
257  quit_button = gtk.Button(stock = gtk.STOCK_QUIT)
258  box.add(exec_button)
259  box.add(text_button)
260  box.add(quit_button)
261 
262  exec_button.connect("clicked", self.cb_show_plot)
263  text_button.connect("clicked", self.cb_show_textview)
264  quit_button.connect("clicked", lambda w: gtk.main_quit())
265 
266  return box
267 
Here is the call graph for this function:

◆ create_header()

def emcalc_gui.MainWindow.create_header (   self)

Definition at line 168 of file emcalc_gui.py.

168  def create_header(self) :
169  hbox = gtk.HBox()
170 
171  label = gtk.Label()
172  label.set_markup("<big><b>EM Calculator</b></big>")
173  hbox.pack_start(label)
174 
175  label = gtk.Label()
176  text = """
177 
178 Shows
179  - stopping power for e/mu/proton
180  - cross sections for gamma
181 """
182  label.set_markup(text)
183  hbox.pack_start(label)
184 
185  return hbox
186 

◆ create_material_frame()

def emcalc_gui.MainWindow.create_material_frame (   self)

Definition at line 227 of file emcalc_gui.py.

227  def create_material_frame(self) :
228  frame = gtk.Frame("Material (G4Nist)")
229 
230  hbox = gtk.HBox()
231  frame.add(hbox)
232  hbox.set_border_width(self.__margin)
233 
234  self.material_list = [ "G4_Al", "G4_Si", "G4_Ar", "G4_Cu", "G4_Fe",
235  "G4_Ge", "G4_Ag", "G4_W", "G4_Au", "G4_Pb",
236  "G4_AIR", "G4_Galactic", "G4_WATER", "G4_CESIUM_IODIDE",
237  "G4_SODIUM_IODIDE", "G4_PLASTIC_SC_VINYLTOLUENE",
238  "G4_MYLAR" ]
239 
240  self.material_combo = gtk.combo_box_entry_new_text()
241  hbox.pack_start(self.material_combo)
242  for name in self.material_list :
243  self.material_combo.append_text(name)
244  self.material_combo.set_active(0)
245  self.material = self.material_list[0]
246  self.material_combo.connect("changed", self.cb_select_material)
247 
248  return frame
249 

◆ create_particle_frame()

def emcalc_gui.MainWindow.create_particle_frame (   self)

Definition at line 187 of file emcalc_gui.py.

187  def create_particle_frame(self) :
188  frame = gtk.Frame("Particle")
189 
190  hbox = gtk.HBox()
191  frame.add(hbox)
192  hbox.set_border_width(self.__margin)
193 
194  button = gtk.RadioButton(None, "electron")
195  button.connect("toggled", self.cb_select_particle, "e-")
196  hbox.pack_start(button, True, True, 0)
197  button.show()
198  self.particle = "e-"
199 
200  button = gtk.RadioButton(button, "positron")
201  button.connect("toggled", self.cb_select_particle, "e+")
202  hbox.pack_start(button, True, True, 0)
203  button.show()
204 
205  button = gtk.RadioButton(button, "mu-")
206  button.connect("toggled", self.cb_select_particle, "mu-")
207  hbox.pack_start(button, True, True, 0)
208  button.show()
209 
210  button = gtk.RadioButton(button, "mu+")
211  button.connect("toggled", self.cb_select_particle, "mu+")
212  hbox.pack_start(button, True, True, 0)
213  button.show()
214 
215  button = gtk.RadioButton(button, "proton")
216  button.connect("toggled", self.cb_select_particle, "proton")
217  hbox.pack_start(button, True, True, 0)
218  button.show()
219 
220  button = gtk.RadioButton(button, "gamma")
221  button.connect("toggled", self.cb_select_particle, "gamma")
222  hbox.pack_start(button, True, True, 0)
223  button.show()
224 
225  return frame
226 
Here is the call graph for this function:

Member Data Documentation

◆ __margin

emcalc_gui.MainWindow.__margin
private

Definition at line 124 of file emcalc_gui.py.

◆ error_dialog

emcalc_gui.MainWindow.error_dialog

Definition at line 163 of file emcalc_gui.py.

◆ mainwindow

emcalc_gui.MainWindow.mainwindow

Definition at line 127 of file emcalc_gui.py.

◆ material

emcalc_gui.MainWindow.material

Definition at line 245 of file emcalc_gui.py.

◆ material_combo

emcalc_gui.MainWindow.material_combo

Definition at line 240 of file emcalc_gui.py.

◆ material_list

emcalc_gui.MainWindow.material_list

Definition at line 234 of file emcalc_gui.py.

◆ particle

emcalc_gui.MainWindow.particle

Definition at line 198 of file emcalc_gui.py.

◆ textview

emcalc_gui.MainWindow.textview

Definition at line 160 of file emcalc_gui.py.


The documentation for this class was generated from the following file: