Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
emcalc_gui.MainWindow Class Reference

Public Member Functions

def __init__
 
def create_header
 
def create_particle_frame
 
def create_material_frame
 
def create_action_box
 
def cb_show_textview
 
def cb_select_particle
 
def cb_select_material
 
def cb_show_plot
 
def cb_close_dialog
 

Public Attributes

 mainwindow
 
 textview
 
 error_dialog
 
 particle
 
 material_list
 
 material_combo
 
 material
 

Detailed Description

Definition at line 122 of file emcalc_gui.py.

Constructor & Destructor Documentation

def emcalc_gui.MainWindow.__init__ (   self)

Definition at line 123 of file emcalc_gui.py.

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

Member Function Documentation

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

Definition at line 295 of file emcalc_gui.py.

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

Definition at line 276 of file emcalc_gui.py.

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

Definition at line 273 of file emcalc_gui.py.

274  def cb_select_particle(self, widget, data=None) :
275  self.particle = data

Here is the caller graph for this function:

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

Definition at line 280 of file emcalc_gui.py.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 269 of file emcalc_gui.py.

270  def cb_show_textview(self, widget, data=None) :
271  window = self.textview.get_window()
272  window.show_all()

Here is the caller graph for this function:

def emcalc_gui.MainWindow.create_action_box (   self)

Definition at line 250 of file emcalc_gui.py.

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

Here is the call graph for this function:

def emcalc_gui.MainWindow.create_header (   self)

Definition at line 168 of file emcalc_gui.py.

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

Definition at line 227 of file emcalc_gui.py.

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

Definition at line 187 of file emcalc_gui.py.

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

Here is the call graph for this function:

Member Data Documentation

emcalc_gui.MainWindow.error_dialog

Definition at line 163 of file emcalc_gui.py.

emcalc_gui.MainWindow.mainwindow

Definition at line 127 of file emcalc_gui.py.

emcalc_gui.MainWindow.material

Definition at line 245 of file emcalc_gui.py.

emcalc_gui.MainWindow.material_combo

Definition at line 240 of file emcalc_gui.py.

emcalc_gui.MainWindow.material_list

Definition at line 234 of file emcalc_gui.py.

emcalc_gui.MainWindow.particle

Definition at line 198 of file emcalc_gui.py.

emcalc_gui.MainWindow.textview

Definition at line 160 of file emcalc_gui.py.


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