-
Notifications
You must be signed in to change notification settings - Fork 25
/
xmlres.py
44 lines (35 loc) · 1.17 KB
/
xmlres.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# The Admin4 Project
# (c) 2013-2022 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
import wx.xrc as xrc
import os, imp
xmlControlList={}
def init(loaddir):
names=os.listdir(loaddir)
found=[]
for name in names:
path="%s/%s" % (loaddir, name)
if os.path.isdir(path):
init(path)
elif name.startswith("ctl_") and name.endswith( (".py", ".pyc")):
name=name[:name.rfind('.')]
if name not in found:
found.append(name)
f, pn, description=imp.find_module(name, [loaddir])
mod=imp.load_module(name, f, pn, description)
xmlControlList.update(mod.xmlControlList)
def getControlClass(name):
return xmlControlList.get(name)
class XmlResourceHandler(xrc.XmlResourceHandler):
def DoCreateResource(self):
cls=xmlControlList.get(self.GetClass())
ctl=None
if cls:
# self.AddStyle("whEXTRAStyle", 4711)
ctl=cls(self.GetParentAsWindow(), cid=self.GetID(), pos=self.GetPosition(), size=self.GetSize(), style=self.GetStyle())
self.SetupWindow(ctl)
return ctl
def CanHandle(self, node):
return node.GetAttribute('class', "") in xmlControlList