Cat
CfgFrame.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 wx.lib.mixins.inspection
14 import sys, os
15 
16 import images
17 from libCatKernel import *
18 
19 from wrapper import *
20 from tools import opj
21 
22 #----------------------------------------------------------------------------
23 class CfgFrame(wx.Frame):
24  overviewText = "CAT Configuration Window"
25  def __init__(self, app, parent, obj , objpath, objtype):
26  wx.Frame.__init__(self, parent, wx.NewId(), objpath)
27  self.parent = parent
28  self.app = app
29  self.obj = obj
30  self.objpath = objpath
31  self.objtype = objtype
32  self.path=os.path.join(os.environ.get("CATPATH"), "CatPython", "python")
33  self.makeToolBar()
34  res=xrc.XmlResource(os.path.join(self.path,"xrc/ConfPanel.xrc"))
35  self.main=res.LoadPanel(self, "ConfPanel")
36  self.Bind(wx.EVT_CLOSE, self.onClose)
37  self.onEdit(obj, objpath, objtype)
38 
39  def onEdit(self, obj, path, objtype):
40  # if (objtype=='element'):
41  # res=xrc.XmlResource(os.path.join(self.path,"xrc/ElementMain.xrc"))
42  # elif (objtype=='proc'):
43  # res=xrc.XmlResource(os.path.join(self.path,"xrc/ProcMain.xrc"))
44  # self.confpanel=res.LoadPanel(self.main,"confpanel")
45  # if (objtype=='element'):
46  # namectrl=self.getControl(self.confpanel,'ObjName')
47  # pathctrl=self.getControl(self.confpanel,'ObjPath')
48  # namectrl.SetValue(obj.name())
49  # pathctrl.SetValue(path)
50  # elif (objtype=='proc'):
51  # namectrl=self.getControl(self.confpanel,'ProcName')
52  # pathctrl=self.getControl(self.confpanel,'ProcPath')
53  # namectrl.SetValue(obj.name())
54  # pathctrl.SetValue(obj.type())
55  # print "self.confpanel=", self.confpanel, self.main
56  # self.panel=self.getControl(self.confpanel,'control')
57  # print "self.panel=",self.panel
58  self.wrap=wrapper(self.app,obj,objtype)
59  self.module=self.wrap.GetActive()
60  self.control=self.module.Edit(self.app,obj,self.main,self.wrap.GetFilePath())
61  self.Show(True)
62 # self.SetAutoLayout(True)
63 
64  def getControl(self, panel, xmlid):
65  '''Retrieves the given control (within a dialog) by its xmlid'''
66  control = panel.FindWindowById(xrc.XRCID(xmlid))
67  assert control != None, 'Programming error: a control with xml id ' + xmlid + ' was not found.'
68  return control
69 
70  def makeToolBar(self):
71  TB_RELOAD=wx.NewId()
72  TB_CLOSEALL=wx.NewId()
73  TB_CLOSE=wx.NewId()
74  #
75  self.toolBar = self.CreateToolBar(wx.TB_DOCKABLE)
76  self.toolBar.AddLabelTool(TB_CLOSE, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/closeall.png")))
77  self.toolBar.AddSeparator()
78  self.toolBar.AddLabelTool(TB_RELOAD, '', wx.Bitmap(os.path.join(self.path,"xrc/icons/reload.png")))
79  self.toolBar.Realize()
80  self.Bind(wx.EVT_TOOL, self.onReLoad , id=TB_RELOAD)
81  self.Bind(wx.EVT_TOOL, self.onClose , id=TB_CLOSE)
82 
83  def onIdle(self, event):
84  '''Responds to idle time in the system'''
85  # when the timer says it's time, we do the actual downloading in the main thread (wx doesn't work well in secondary threads)
86  print "hello"
87 
88  def onIconize(self, event):
89  print "onIconize"
90  self.parent.cfgFrame.Show(False)
91  self.parent.cfgState=False
92 
93  def onChange(self, event):
94  print "OnChange"
95  self.update()
96 
97  def onReLoad(self, event):
98  self.update()
99 
100  def onClose(self, event):
101  for p in range(len(self.parent.paths)):
102  if self.parent.paths[p] == self.objpath:
103  self.parent.cfgpanels.pop(p)
104  self.parent.objs.pop(p)
105  self.parent.paths.pop(p)
106  break
107  self.Destroy()
108 
109  def update(self):
110  self.control.update()
111 
112 #----------------------------------------------------------------------------
113 
114 
115 
def __init__(self, app, parent, obj, objpath, objtype)
Definition: CfgFrame.py:25
def makeToolBar(self)
Definition: CfgFrame.py:70
def update(self)
Definition: CfgFrame.py:109
def getControl(self, panel, xmlid)
Definition: CfgFrame.py:64
def Edit(cat, obj, panel, path)
Definition: Croc.py:15
def onIdle(self, event)
Definition: CfgFrame.py:83
def onIconize(self, event)
Definition: CfgFrame.py:88
def onChange(self, event)
Definition: CfgFrame.py:93
def onReLoad(self, event)
Definition: CfgFrame.py:97
def onEdit(self, obj, path, objtype)
Definition: CfgFrame.py:39
def onClose(self, event)
Definition: CfgFrame.py:100