3
from wxPython.wx import *
4
from wxPython.xrc import *
6
from Companions import BaseCompanions
8
class XmlResourceDTC(BaseCompanions.UtilityDTC):
9
handledConstrParams = ()
10
def __init__(self, name, designer, objClass):
11
BaseCompanions.UtilityDTC.__init__(self, name, designer, objClass)
12
self.editors['FileMask'] = StrConstrPropEdit
14
## def hideDesignTime(self):
16
def constructor(self):
17
return {'FileMask': 'filemask', 'Name': 'name'}
18
def designTimeSource(self, position='wxDefaultPos', size='wxDefaultSize'):
19
return {'filemask': "''"}
20
def writeImports(self):
21
return 'from wxPython.xrc import *'
23
factoryDict = {'LoadPanel' : 'XrcPanel'}
24
def factory(self, method):
25
return self.factoryDict.get(method, None)
27
from Companions import ContainerCompanions
30
class XrcPanelDTC(ContainerCompanions.PanelDTC):
31
suppressWindowId = true
32
def constructor(self):
33
return {'Name': 'name'}
35
def designTimeControl(self, position, size, args = None):
36
""" Create and initialise a design-time control """
39
self.control = apply(self.ctrlClass, (), args)
41
self.control = apply(self.ctrlClass, (), self.designTimeDefaults(position, size))
43
self.initDesignTimeControl()
46
def designTimeDefaults(self, position = wxDefaultPosition,
47
size = wxDefaultSize):
48
xrcObjs = self.designer.getObjectsOfClass(wxXmlResource)
50
raise 'No wxXmlResource objects found'
51
# factory/LoadPage allows no positional info
52
if not position: posx, posy = 0, 0
53
else: posx, posy = position.x, position.y
54
return {'parent': self.parent, 'id': -1, 'pos': (posx, posy),
58
def persistConstr(self, className, params):
60
for param in params.keys():
61
paramStrs.append('%s = %s'%(param, params[param]))
63
if not self.textConstr:
64
xrcObjs = self.designer.getObjectsOfClass(wxXmlResource)
65
names = xrcObjs.keys()
67
dlg = wxSingleChoiceDialog(self.designer, 'Select wxXmlResource to LoadPanel from',
68
'wxXmlResource.LoadPanel', names)
70
if dlg.ShowModal() == wxID_OK:
71
xrcObj = dlg.GetStringSelection()
72
self.xmlResource = string.split(xrcObj, '.')[1]
78
raise 'No wxXmlResource objects found'
80
self.xmlResource = self.textConstr.factory[0]
82
self.textConstr = methodparse.ConstructorParse(
83
'self.%s = self.%s.LoadPanel(%s)'%(self.name, self.xmlResource,
84
string.join(paramStrs, ', ')))
86
self.designer.addCtrlToObjectCollection(self.textConstr)
88
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
89
return {'name': `self.name`}
92
class XrcPanel(wxPanel):
96
PaletteStore.paletteLists['Utilities (Data)'].append(wxXmlResource)
97
PaletteStore.compInfo.update({wxXmlResource: ['wxXmlResource', XmlResourceDTC]})
98
PaletteStore.paletteLists['ContainersLayout'].append(XrcPanel)
99
PaletteStore.compInfo[XrcPanel] = ['XrcPanel', XrcPanelDTC]
4
from Companions import BaseCompanions
6
class XmlResourceDTC(BaseCompanions.UtilityDTC):
7
handledConstrParams = ()
8
def __init__(self, name, designer, objClass):
9
BaseCompanions.UtilityDTC.__init__(self, name, designer, objClass)
10
self.editors['FileMask'] = StrConstrPropEdit
12
## def hideDesignTime(self):
14
def constructor(self):
15
return {'FileMask': 'filemask', 'Name': 'name'}
16
def designTimeSource(self, position='wx.DefaultPos', size='wx.DefaultSize'):
17
return {'filemask': "''"}
18
def writeImports(self):
19
return 'import wx.xrc'
21
factoryDict = {'LoadPanel' : 'XrcPanel'}
22
def factory(self, method):
23
return self.factoryDict.get(method, None)
25
from Companions import ContainerCompanions
28
class XrcPanelDTC(ContainerCompanions.PanelDTC):
29
suppressWindowId = True
30
def constructor(self):
31
return {'Name': 'name'}
33
def designTimeControl(self, position, size, args = None):
34
""" Create and initialise a design-time control """
37
self.control = apply(self.ctrlClass, (), args)
39
self.control = apply(self.ctrlClass, (), self.designTimeDefaults(position, size))
41
self.initDesignTimeControl()
44
def designTimeDefaults(self, position = wx.DefaultPosition,
45
size = wx.DefaultSize):
46
xrcObjs = self.designer.getObjectsOfClass(wx.xrc.XmlResource)
48
raise 'No wx.xrc.XmlResource objects found'
49
# factory/LoadPage allows no positional info
50
if not position: posx, posy = 0, 0
51
else: posx, posy = position.x, position.y
52
return {'parent': self.parent, 'id': -1, 'pos': (posx, posy),
56
def persistConstr(self, className, params):
58
for param in params.keys():
59
paramStrs.append('%s = %s'%(param, params[param]))
61
if not self.textConstr:
62
xrcObjs = self.designer.getObjectsOfClass(wx.xrc.XmlResource)
63
names = xrcObjs.keys()
65
dlg = wx.SingleChoiceDialog(self.designer, 'Select wx.xrc.XmlResource to LoadPanel from',
66
'wx.xrc.XmlResource.LoadPanel', names)
68
if dlg.ShowModal() == wx.ID_OK:
69
xrcObj = dlg.GetStringSelection()
70
self.xmlResource = xrcObj.split('.')[1]
76
raise 'No wx.xrc.XmlResource objects found'
78
self.xmlResource = self.textConstr.factory[0]
80
self.textConstr = methodparse.ConstructorParse(
81
'self.%s = self.%s.LoadPanel(%s)'%(self.name, self.xmlResource,
82
', '.join(paramStrs)))
84
self.designer.addCtrlToObjectCollection(self.textConstr)
86
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
87
return {'name': `self.name`}
90
class XrcPanel(wx.Panel):
93
#-------------------------------------------------------------------------------
97
Plugins.registerComponent('Utilities (Data)', wx.xrc.XmlResource,
98
'wx.xrc.XmlResource', XmlResourceDTC)
99
Plugins.registerComponent('ContainersLayout', XrcPanel,
100
'XrcPanel', XrcPanelDTC)