Cat
AppFrame.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------------
3 #----------------------------------------------------------------------------
4 
5 """
6 This program will load and run one of the individual demos in this
7 directory within its own frame window. Just specify the module name
8 on the command line.
9 """
10 
11 import wx
12 import wx.xrc as xrc
13 import images
14 import wx.lib.mixins.inspection
15 from wx.lib.mixins.treemixin import ExpansionState
16 import sys, os
17 
18 import images
19 from tree import *
20 
21 #from GraphFrame import *
22 #from LogFrame import *
23 from CfgFrame import *
24 
25 from libCatKernel import *
26 
27 from tools import opj
28 
29 from shell import *
30 
31 #from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
32 #from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar
33 
34 global cat
35 
36 _objectTypes = ["Overview", "demo", "Processus","Doc", "Data","Doc"]
37 
38 _treeList = [
39  ('Elements', []),
40  ('Processus', []),
41  ('Data', []),
42  ('Documents', []),
43  ('Libraries', []),
44 ]
45 
46 _windows = [
47  ('App',[True,[0.01,0.04],[0.30,0.60]]),
48 # ('Log',[False,[0.03,0.45],[0.90,0.50]]),
49 # ('Cfg',[False,[0.41,0.01],[0.58,0.90]]),
50  ('Gph',[False,[0.13,0.13],[0.75,0.75]])
51  ]
52 
53 #----------------------------------------------------------------------------
54 class AppFrame(wx.Frame):
55  overviewText = "CAT Main Window"
56  def __init__(self, app, parent, title):
57  wx.Frame.__init__(self, parent, wx.NewId(), title, size=(500, 650))
58 
59  self.MB_CONF=wx.NewId()
60  self.MB_GRAPH=wx.NewId()
61  self.MB_LOG=wx.NewId()
62 
63  self.TB_CONF=wx.NewId()
64  self.TB_GRAPH=wx.NewId()
65  self.TB_LOG=wx.NewId()
66 
67  self.cfgpanels=list()
68  self.objs=list()
69  self.paths=list()
70 
71  global cat
72  cat=app
73 
74  self.path=os.path.join(os.environ.get("CATPATH"),"CatPython","python")
75  sizeX=wx.SystemSettings.GetMetric( wx.SYS_SCREEN_X );
76  sizeY=wx.SystemSettings.GetMetric( wx.SYS_SCREEN_Y );
77  self.makeMenuBar()
78  self.makeToolBar()
79  res=xrc.XmlResource(os.path.join(self.path,"xrc/AppPanel.xrc"))
80  self.panel=res.LoadPanel(self, "AppPanel")
81 # self.makeFrames()
82 
83  for window, items in _windows:
84  show=items[0]
85  Pt=wx.Point(items[1][0]*sizeX,items[1][1]*sizeY)
86  Sz=wx.Size(items[2][0]*sizeX,items[2][1]*sizeY)
87  if window=='App':
88  self.Move(Pt)
89  self.SetSize(Sz)
90  # if window=='Cfg':
91  # self.cfgFrame.Move(Pt)
92  # self.cfgFrame.SetSize(Sz)
93  # self.cfgState=show
94  # self.cfgFrame.Show(show)
95  # self.toolBar.ToggleTool(self.TB_CONF, show)
96  # menuItem = self.menuBar.FindItemById(self.MB_CONF)
97  # menuItem.Check(show)
98 
99  # if window=='Gph':
100  # self.gphFrame.Move(Pt)
101  # self.gphFrame.SetSize(Sz)
102  # self.gphState=show
103  # self.gphFrame.Show(show)
104  # self.toolBar.ToggleTool(self.TB_GRAPH, show)
105  # menuItem = self.menuBar.FindItemById(self.MB_GRAPH)
106  # menuItem.Check(show)
107 
108  # if window=='Log':
109  # self.logFrame.Move(Pt)
110  # self.logFrame.SetSize(Sz)
111  # self.logState=show
112  # self.logFrame.Show(show)
113  # self.toolBar.ToggleTool(self.TB_LOG, show)
114  # menuItem = self.menuBar.FindItemById(self.MB_LOG)
115  # menuItem.Check(show)
116 
117  self.treeContainer=xrc.XRCCTRL(self, 'TreePanel')
118  self.vbox=wx.BoxSizer(wx.VERTICAL)
119 
121 
122  self.vbox.Add(self.tree,1,wx.EXPAND)
123  self.treeContainer.SetSizer( self.vbox )
124 
125 # self.tree
126 # self.treeMap = {}
127 
128 # self.BuildTreeImageList()
129  #self.tree.SetExpansionState(self.expansionState)
130 # self.tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
131 # self.tree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed)
132 # self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
133 # self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnTreeLeftDown)
134 
135  self.elementCombo=self.getControl("elementCombo")
136  self.procCombo=self.getControl("procCombo")
137  self.Bind(wx.EVT_COMBOBOX, self.updateCombo, id=xrc.XRCID("elementCombo"))
138  self.Bind(wx.EVT_BUTTON, self.onLoad, id=xrc.XRCID("openConfFile"))
139  self.Bind(wx.EVT_BUTTON, self.onEdit, id=xrc.XRCID("onEdit"))
140  self.Bind(wx.EVT_SPINCTRL, self.runCtrl, id=xrc.XRCID("runCtrl"))
141  self.Bind(wx.EVT_SPINCTRL, self.eventCtrl, id=xrc.XRCID("eventCtrl"))
142  self.Bind(wx.EVT_SPINCTRL, self.printFreq, id=xrc.XRCID("printFreq"))
143  self.Bind(wx.EVT_SPINCTRL, self.plotFreq, id=xrc.XRCID("plotFreq"))
144  self.Bind(wx.EVT_TEXT_ENTER, self.onEnter, id=xrc.XRCID("cmdline"))
145  self.Bind(wx.EVT_BUTTON, self.onEnter, id=xrc.XRCID("onEnter"))
146  self.Bind(wx.EVT_BUTTON, self.onExpand, id=xrc.XRCID("onExpand"))
147  self.Bind(wx.EVT_BUTTON, self.onCollapse, id=xrc.XRCID("onCollapse"))
148  self.Bind(wx.EVT_BUTTON, self.deleteHardware, id=xrc.XRCID("deleteHardware"))
149  self.Bind(wx.EVT_TOGGLEBUTTON, self.onAutoCheck, id=xrc.XRCID("autoCheck"))
150  self.Bind(wx.EVT_TOGGLEBUTTON, self.onStopOnError, id=xrc.XRCID("stoponerror"))
151  self.Bind(wx.EVT_TOGGLEBUTTON, self.onLogCheck, id=xrc.XRCID("logCheck"))
152  self.Bind(wx.EVT_TOGGLEBUTTON, self.onFileCheck, id=xrc.XRCID("fileCheck"))
153  self.Bind(wx.EVT_COMBOBOX, self.updateOutputLevel, id=xrc.XRCID("outputLevel"))
154  self.update()
155 
156  def getControl(self, xmlid):
157  '''Retrieves the given control (within a dialog) by its xmlid'''
158  control = self.FindWindowById(xrc.XRCID(xmlid))
159 # print xmlid
160 # print xrc.XRCID(xmlid)
161 # print control
162  if control == None and self.GetMenuBar() != None: # see if on the menubar
163  control = self.GetMenuBar().FindItemById(xrc.XRCID(xmlid))
164  assert control != None, 'Programming error: a control with xml id ' + xmlid + ' was not found.'
165  return control
166 
167  def makeMenuBar(self):
168  MB_FILE=wx.NewId()
169  MB_CLOSE=wx.NewId()
170  #
171  file=wx.Menu()
172  file.Append(MB_FILE,"&File","Open new configuration file")
173  file.Append(MB_CLOSE,"&Close","Close configuration file")
174  file.Append(wx.ID_EXIT, "E&xit", "Terminate the program")
175  windows=wx.Menu()
176 # windows.AppendCheckItem(self.MB_CONF,"&Configuration window","Configuration window")
177 # windows.AppendCheckItem(self.MB_GRAPH,"&Graphic window","Graphic window")
178 # windows.AppendCheckItem(self.MB_LOG,"&Log window","Log window")
179  help=wx.Menu()
180  help.Append(wx.ID_ABOUT, "&About","More information about this program")
181  help.AppendSeparator()
182  help.Append(wx.ID_HELP, "&Help", "CAT application help")
183  self.menuBar=wx.MenuBar(wx.MB_DOCKABLE)
184  self.menuBar.Append(file , "&File")
185  self.menuBar.Append(windows, "&Windows")
186  self.menuBar.Append(help , "&Help")
187  self.SetMenuBar(self.menuBar)
188  self.Bind(wx.EVT_MENU, self.onExit , id=wx.ID_EXIT )
189  self.Bind(wx.EVT_MENU, self.onAbout , id=wx.ID_ABOUT )
190  self.Bind(wx.EVT_MENU, self.onHelp , id=wx.ID_HELP )
191 # self.Bind(wx.EVT_MENU, self.onCheckGraph, id=self.MB_GRAPH )
192 # self.Bind(wx.EVT_MENU, self.onCheckLog , id=self.MB_LOG )
193 # self.Bind(wx.EVT_MENU, self.onCheckConf , id=self.MB_CONF )
194  self.Bind(wx.EVT_MENU, self.onLoad , id=MB_FILE )
195  self.Bind(wx.EVT_MENU, self.onClose , id=MB_CLOSE )
196 
197  def makeToolBar(self):
198  TB_OPEN=wx.NewId()
199  TB_RELOAD=wx.NewId()
200  TB_CONFIGURE=wx.NewId()
201  TB_INIT=wx.NewId()
202  TB_DELETE=wx.NewId()
203  TB_START=wx.NewId()
204  TB_SINGLE=wx.NewId()
205  TB_EXIT=wx.NewId()
206  #
207  self.toolBar = self.CreateToolBar(wx.TB_DOCKABLE)
208  self.toolBar.AddLabelTool(TB_OPEN , '', wx.Bitmap(os.path.join(self.path,"xrc/icons/fileopen.png")))
209  self.toolBar.AddLabelTool(TB_RELOAD, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/reload.png")))
210  self.toolBar.AddLabelTool(TB_CONFIGURE, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/conf.png")))
211  self.toolBar.AddLabelTool(TB_INIT, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/init.png")))
212  self.toolBar.AddLabelTool(TB_DELETE, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/delete.png")))
213  self.toolBar.AddSeparator()
214 # self.toolBar.AddCheckLabelTool(self.TB_CONF, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/config.png")))
215  self.toolBar.AddCheckLabelTool(self.TB_GRAPH, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/graph.png")))
216 # self.toolBar.AddCheckLabelTool(self.TB_LOG, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/log.png")))
217  self.toolBar.AddSeparator()
218  self.toolBar.AddLabelTool(TB_START, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/start.png")))
219  self.toolBar.AddLabelTool(TB_SINGLE, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/single.png")))
220  self.toolBar.AddSeparator()
221  self.toolBar.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/exit.png")))
222  self.toolBar.Realize()
223  self.Bind(wx.EVT_TOOL, self.onExit , id=wx.ID_EXIT)
224 # self.Bind(wx.EVT_TOOL, self.onCheckGraph, id=self.TB_GRAPH)
225 # self.Bind(wx.EVT_TOOL, self.onCheckLog , id=self.TB_LOG)
226 # self.Bind(wx.EVT_TOOL, self.onCheckConf , id=self.TB_CONF)
227  self.Bind(wx.EVT_TOOL, self.onLoad , id=TB_OPEN)
228  self.Bind(wx.EVT_TOOL, self.onReLoad , id=TB_RELOAD)
229  self.Bind(wx.EVT_TOOL, self.onConfigure , id=TB_CONFIGURE)
230  self.Bind(wx.EVT_TOOL, self.onInit , id=TB_INIT)
231  self.Bind(wx.EVT_TOOL, self.onDelete , id=TB_DELETE)
232  self.Bind(wx.EVT_TOOL, self.onStart , id=TB_START)
233  self.Bind(wx.EVT_TOOL, self.onSingle , id=TB_SINGLE)
234 
235 # def makeFrames(self):
236 # self.logFrame=LogFrame(cat, self, "Log window")
237 # self.cfgFrame=ConfFrame(cat, self, "Configuration window")
238 # self.gphFrame=GraphFrame(cat, self, "Graphical window")
239 
240  def onIdle(self, event):
241  '''Responds to idle time in the system'''
242  # when the timer says it's time, we do the actual downloading in the main thread (wx doesn't work well in secondary threads)
243  print "onIdle"
244 
245  def onCloseConfirm(self, event):
246  '''Closes the application'''
247  dlg = wx.MessageDialog(self, "Exit the program?", "Exit", wx.YES_NO | wx.ICON_QUESTION)
248  if dlg.ShowModal() == wx.ID_YES:
249  dlg.Destroy() # frame
250  self.Destroy()
251 
252  def onClose(self, event):
253  '''Closes the application'''
254  self.Destroy()
255 
256  def onExit(self, event):
257  '''Exit the app'''
258  self.Close(True)
259 # exit(2)
260 
261  def onHelp(self, event):
262  '''Help'''
263  print "help"
264 
265  def onAbout(self, event):
266  '''About'''
267  print "about"
268 
269  def onAutoCheck(self, event):
270  cat.options().setRunNumberMgr(self.getControl("autoCheck").GetValue())
271  print cat.options().runNumberMgr()
272 
273  def onStopOnError(self, event):
274  cat.options().setStopOnError(self.getControl("stoponerror").GetValue())
275 
276  def onFileCheck(self, event):
277  cat.options().setDataStorage(self.getControl("fileCheck").GetValue())
278  print cat.options().dataStorage()
279 
280  def onLogCheck(self, event):
281  cat.options().setLogStorage(self.getControl("logCheck").GetValue())
282  print cat.options().logStorage()
283 
284  def eventCtrl(self,event):
285  cat.options().setNEvtMax(self.getControl("eventCtrl").GetValue())
286 
287  def runCtrl(self,event):
288  cat.options().setRunNumber(self.getControl("runCtrl").GetValue())
289 
290  def printFreq(self,event):
291  cat.options().setPrintFreq(self.getControl("printFreq").GetValue())
292 
293  def plotFreq(self,event):
294  cat.options().setPlotFreq(self.getControl("plotFreq").GetValue())
295 
296  def onEnter(self,event):
297  cmd=self.getControl("cmdline").GetValue()
298  self.getControl("cmdline").SetValue("")
299  exec(cmd)
300 
301  # Graphical Window management
302  # def onCheckGraph(self, event):
303  # state=not self.gphState
304  # self.gphState=state
305  # self.gphFrame.Show(state)
306  # self.toolBar.ToggleTool(self.TB_GRAPH, state)
307  # menuItem = self.menuBar.FindItemById(self.MB_GRAPH)
308  # menuItem.Check(state)
309 
310  # Log Window management
311  # def onCheckLog(self, event):
312  # state=not self.logState
313  # self.logState=state
314  # self.logFrame.Show(state)
315  # self.toolBar.ToggleTool(self.TB_LOG, state)
316  # menuItem = self.menuBar.FindItemById(self.MB_LOG)
317  # menuItem.Check(state)
318 
319  # Configuration Window management
320  # def onCheckConf(self, event):
321  # state=not self.cfgState
322  # self.cfgState=state
323  # self.cfgFrame.Show(state)
324  # self.toolBar.ToggleTool(self.TB_CONF, state)
325  # menuItem = self.menuBar.FindItemById(self.MB_CONF)
326  # menuItem.Check(state)
327 
328  def onLoad(self, event):
329  path=[]
330  dlg = wx.FileDialog(
331  self, message="Choose a file",
332  defaultDir=os.getcwd(),
333  defaultFile="",
334  wildcard="Python source (*.py)|*.py|" "All files (*.*)|*.*",
335  style=wx.OPEN | wx.CHANGE_DIR
336  )
337 
338  # Show the dialog and retrieve the user response. If it is the OK response,
339  # process the data.
340  if dlg.ShowModal() == wx.ID_OK:
341  # This returns a Python list of files that were selected.
342  path = dlg.GetPaths()
343  # Destroy the dialog. Don't do this until you are done with it!
344  # BAD things can happen otherwise!
345  dlg.Destroy()
346  if len(path)==1:
347  filename=str(path[0])
348  execfile(filename)
349  cat.options().setDefFile(filename)
350  cat.computer().tree()
351  self.update()
352 
353  # def onEdit(self, event):
354  # objtype=self.tree.GetItem()
355  # if (objtype[1]=='Element'):
356  # self.cfgFrame.onEdit(cat.computer().child(objtype[0]),objtype[0],'element')
357  # self.cfgFrame.Show(True)
358  # self.cfgFrame.show=True
359  # if (objtype[1]=='Processus'):
360  # list=[]
361  # listPtr=cat.procDb().list()
362  # for proc in range(len(listPtr)):
363  # if (objtype[0]==listPtr[proc].name()):
364  # processus=listPtr[proc]
365  # self.cfgFrame.onEdit(processus,objtype[0],'proc')
366  # self.cfgFrame.Show(True)
367  # self.cfgFrame.show=True
368 
369  def onEdit(self, event):
370  objtype=self.tree.GetItem()
371 # print "objtype is : ",objtype
372  objpanel=-1
373  for i in range(len(self.objs)):
374  if objtype[0]==self.paths[i]:
375  self.cfgpanels[objpanel].update()
376  self.cfgpanels[objpanel].Show(True)
377  return
378 
379  self.paths.append(objtype[0])
380  if (objtype[1]=='Element'):
381  self.objs.append(cat.computer().child(objtype[0]))
382  self.cfgpanels.append(CfgFrame(cat, self, self.objs[-1], objtype[0], "element"))
383 
384  if (objtype[1]=='Processus'):
385  list = cat.procDb().list()
386  for p in range(len(list)):
387  if list[p].name()==objtype[0]:
388  self.objs.append(list[p])
389  self.cfgpanels.append(CfgFrame(cat, self, self.objs[-1], objtype[0], "proc"))
390  break
391 
392  def deleteHardware(self, event):
393  objtype=self.tree.GetItem()
394  cat.warning("Removing object "+objtype[0]+" of type "+objtype[1])
395  element=cat.computer().child(objtype[0])
396  if (element!=0):
397  cat.computer().delChild(element)
398  self.update()
399 
400  def onExpand(self, event):
401  self.tree.ExpandAll()
402 
403  def onCollapse(self, event):
404  self.tree.CollapseAll()
405 
406  def onReLoad(self, event):
407  reload()
408  cat.computer().tree()
409  self.update()
410 
411  def onConfigure(self, event):
412  print "Not implemented yet"
413 
414  def onInit(self, event):
415  init()
416 
417  def onDelete(self, event):
418  cat.computer().clear()
419 
420  def onStart(self, event):
421  cat.options().setStorageDir(str(self.getControl("fileCtrl").GetValue()))
422  cat.options().setStoragePath(str(self.getControl("pathCtrl").GetValue()))
423  item=self.elementCombo.GetSelection()
424  element=cat.computer().child(self.listElement[item])
425  list=cat.procDb().list(element)
426  processus=list[self.procCombo.GetSelection()]
427  nevt=self.getControl("eventCtrl").GetValue()
428 
429  dlg = wx.ProgressDialog(processus.title(),
430  processus.name(),
431  maximum = abs(nevt),
432  parent=self,
433  style = wx.PD_CAN_ABORT
434  | wx.PD_APP_MODAL
435  | wx.PD_ELAPSED_TIME
436  | wx.PD_ESTIMATED_TIME
437  | wx.PD_REMAINING_TIME
438  )
439  plts = None
440  module = None
441  processus.setElement(element)
442  wrap = wrapper(cat, processus, "proc")
443 
444  online = cat.options().plotFreq()
445 
446  if (wrap.ok):
447  module = wrap.GetActive()
448  if module and online!=0 :
449  plts = module.createPlots(cat, processus, cat.options().runNumber())
450 
451  keepGoing = True
452 
453  timing = -1
454  if (nevt<0):
455  timing = time.time()
456  evt = abs(nevt)
457 
458  ievt=0
459  status=Code.SUCCESS
460  dlg.Update(ievt, " Initializing"+processus.name())
461  cat.prepare(processus.name(),element,nevt)
462  while (keepGoing):
463  ievt+=1
464  status=cat.loop()
465  if online>0 and plt:
466  if module and ievt%online==0:
467  module.updatePlots(plts, processus)
468  if timing>=0:
469  elapsed = time.time() - timing
470  (keepGoing, skip)=dlg.Update(elapsed,"Running "+processus.name())
471  if elapsed > evt: keepGoing = False
472  else:
473  (keepGoing, skip)=dlg.Update(ievt,"Running "+processus.name())
474  if ievt >= evt: keepGoing = False
475  dlg.Update(evt,"Finalizing "+processus.name())
476  cat.terminate()
477 
478  if module and online==0:
479  plts = module.createPlots(cat, processus, cat.options().runNumber())
480  if plts :
481  module.updatePlots(plts, processus)
482 
483  dlg.Destroy()
484 
485 # self.plot(processus,False)
486 # self.getControl("runCtrl").SetValue(cat.options().runNumber())
487 
488 
489  def onSingle(self, event):
490  cat.options().setStorageDir(str(self.getControl("fileCtrl").GetValue()))
491  cat.options().setStoragePath(str(self.getControl("pathCtrl").GetValue()))
492  item=self.elementCombo.GetSelection()
493  element=cat.computer().child(self.listElement[item])
494  list=cat.procDb().list(element)
495  processus=list[self.procCombo.GetSelection()]
496  cat.prepare(processus.name(),element,1)
497  cat.loop()
498  cat.terminate()
499  self.plot(processus,False)
500  self.getControl("runCtrl").SetValue(cat.options().runNumber())
501 
502 
503  def plot(self, proc, force):
504  self.gphFrame.onPlot(proc)
505  if (force):
506  self.gphFrame.Show(True)
507  self.gphFrame.show=True
508 
509 
510  #---------------------------------------------
511  def BuildElementList(self):
512  def sublevel(list, element):
513  if (element.hasChildren()):
514  newlist=[]
515  children=element.children()
516  for child in range(len(children)):
517  newlist.append(children[child].name())
518  if (children[child].hasChildren()):
519  sublevel(newlist,children[child])
520  list.append(newlist)
521  list=[]
522  list.append(cat.computer().name())
523  sublevel(list,cat.computer())
524  return list
525 
526  #---------------------------------------------
528  list=[]
529  listPtr=cat.procDb().list()
530  for proc in range(len(listPtr)):
531  list.append(listPtr[proc].name())
532  return list
533 
534  def update(self):
535  # Update options
536  self.getControl("cdffileCtrl").SetValue(cat.options().defFile());
537  self.getControl("printFreq").SetValue(cat.options().printFreq())
538  self.getControl("plotFreq").SetValue(cat.options().plotFreq())
539  self.getControl("eventCtrl").SetValue(cat.options().nEvtMax())
540  self.getControl("runCtrl").SetValue(cat.options().runNumber())
541  self.getControl("errorCtrl").SetValue(str(cat.options().nErrors()))
542  self.getControl("fileCtrl").SetValue(cat.options().storageDir())
543  self.getControl("pathCtrl").SetValue(cat.options().storagePath())
544  self.getControl("stoponerror").SetValue(cat.options().stopOnError())
545  self.getControl("autoCheck").SetValue(cat.options().runNumberMgr())
546  self.getControl("fileCheck").SetValue(cat.options().dataStorage())
547  self.getControl("logCheck").SetValue(cat.options().logStorage())
548  level=cat.options().logOutputLevel()
549  combo=self.getControl("outputLevel")
550  if level==MsgLevel.VERBOSE:
551  combo.SetSelection(0)
552  if level==MsgLevel.DEBUG:
553  combo.SetSelection(1)
554  if level==MsgLevel.INFO:
555  combo.SetSelection(2)
556  if level==MsgLevel.WARNING:
557  combo.SetSelection(3)
558  if level==MsgLevel.ERROR:
559  combo.SetSelection(4)
560  if level==MsgLevel.FATAL:
561  combo.SetSelection(5)
562  # Tree control
563 # self.RecreateTree()
564 # self.tree.SelectItem(self.root)
565  self.elementCombo.Clear()
567  index = 0
568  current = 0
569  for i in self.listElement:
570  if (i==cat.current().path("")):
571  current=index
572  index=index+1
573  self.elementCombo.Append(i)
574  self.elementCombo.SetSelection(current)
575  self.procComboUpdate(cat.current());
577 
578  def ElementList(self):
579  def sublevel(list, element):
580  if (element.hasChildren()):
581  children=element.children()
582  for child in range(len(children)):
583  if (len(cat.procDb().list(children[child]))>0):
584  list.append(children[child].path(""))
585  if (children[child].hasChildren()):
586  sublevel(list,children[child])
587 
588  list=[]
589  list.append(cat.computer().path(""))
590  sublevel(list,cat.computer())
591  return list
592 
593  def updateCombo(self, event):
594  item=event.GetSelection()
595  if item==0:
596  element=cat.computer()
597  else:
598  element=cat.computer().child(self.listElement[item])
599  self.procComboUpdate(element)
600 
601  def updateOutputLevel(self, event):
602  level=self.getControl("outputLevel").GetValue()
603  if level=="Verbose":
604  cat.options().setLogOutputLevel(MsgLevel.VERBOSE)
605  if level=="Debug":
606  cat.options().setLogOutputLevel(MsgLevel.DEBUG)
607  if level=="Info":
608  cat.options().setLogOutputLevel(MsgLevel.INFO)
609  if level=="Warning":
610  cat.options().setLogOutputLevel(MsgLevel.WARNING)
611  if level=="Error":
612  cat.options().setLogOutputLevel(MsgLevel.ERROR)
613  if level=="Fatal Error":
614  cat.options().setLogOutputLevel(MsgLevel.FATAL)
615  print cat.options().logOutputLevel()
616 
617  def procComboUpdate(self, element):
618  self.procCombo.Clear()
619  self.procCombo.Remove(0,self.procCombo.GetLastPosition()+1)
620  list=cat.procDb().list(element)
621  for i in range(len(list)):
622  self.procCombo.Append(list[i].name())
623  self.procCombo.SetSelection(0)
624 
625 #----------------------------------------------------------------------------
def onClose(self, event)
Definition: AppFrame.py:252
def onHelp(self, event)
Definition: AppFrame.py:261
def onLoad(self, event)
Definition: AppFrame.py:328
def updateCombo(self, event)
Definition: AppFrame.py:593
def BuildProcessusList(self)
Definition: AppFrame.py:527
def RecreateTree(self, myElements, myProcessus)
Definition: tree.py:224
def onExit(self, event)
Definition: AppFrame.py:256
def makeMenuBar(self)
Definition: AppFrame.py:167
def onEdit(self, event)
Definition: AppFrame.py:369
def onCollapse(self, event)
Definition: AppFrame.py:403
def eventCtrl(self, event)
Definition: AppFrame.py:284
def onExpand(self, event)
Definition: AppFrame.py:400
def deleteHardware(self, event)
Definition: AppFrame.py:392
def CollapseAll(self)
Definition: tree.py:301
def onSingle(self, event)
Definition: AppFrame.py:489
def __init__(self, app, parent, title)
Definition: AppFrame.py:56
def plotFreq(self, event)
Definition: AppFrame.py:293
def printFreq(self, event)
Definition: AppFrame.py:290
def makeToolBar(self)
Definition: AppFrame.py:197
def ElementList(self)
Definition: AppFrame.py:578
def onIdle(self, event)
Definition: AppFrame.py:240
def GetItem(self)
self.root = self.tree.AddRoot("The Root Item") self.tree.SetPyData(self.root, None) self...
Definition: tree.py:89
def onCloseConfirm(self, event)
Definition: AppFrame.py:245
def onInit(self, event)
Definition: AppFrame.py:414
def onDelete(self, event)
Definition: AppFrame.py:417
def onStart(self, event)
Definition: AppFrame.py:420
def update(self)
Definition: AppFrame.py:534
def BuildElementList(self)
Definition: AppFrame.py:511
def onFileCheck(self, event)
Definition: AppFrame.py:276
def plot(self, proc, force)
Definition: AppFrame.py:503
def onEnter(self, event)
Definition: AppFrame.py:296
def onAbout(self, event)
Definition: AppFrame.py:265
def onAutoCheck(self, event)
Definition: AppFrame.py:269
def procComboUpdate(self, element)
Definition: AppFrame.py:617
def runCtrl(self, event)
Definition: AppFrame.py:287
def clear(path='')
Definition: shell.py:172
def getControl(self, xmlid)
Definition: AppFrame.py:156
def onReLoad(self, event)
Definition: AppFrame.py:406
def onStopOnError(self, event)
Definition: AppFrame.py:273
def updateOutputLevel(self, event)
Definition: AppFrame.py:601
Definition: tree.py:1
def ExpandAll(self)
Definition: tree.py:298
def reload()
Definition: shell.py:50
def init()
Definition: shell.py:203
def onConfigure(self, event)
Definition: AppFrame.py:411
def onLogCheck(self, event)
Definition: AppFrame.py:280