Support for custom controls, first attempt
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -902,6 +902,18 @@ class XML_Tree(wx.TreeCtrl):
|
|||||||
if not g.currentEncoding:
|
if not g.currentEncoding:
|
||||||
xmlFlags != xrc.XRC_USE_LOCALE
|
xmlFlags != xrc.XRC_USE_LOCALE
|
||||||
res = xrc.XmlResource('', xmlFlags)
|
res = xrc.XmlResource('', xmlFlags)
|
||||||
|
xrc.XmlResource.Set(res) # set as global
|
||||||
|
# Register handlers
|
||||||
|
addHandlers(res)
|
||||||
|
# Test Test.py
|
||||||
|
#import Test
|
||||||
|
#res.InsertHandler(Test.TestXmlHandler())
|
||||||
|
# Test test.so
|
||||||
|
import ctypes
|
||||||
|
test = ctypes.CDLL('test.so')
|
||||||
|
addr = int(str(res.this).split('_')[1], 16)
|
||||||
|
#test._Z17AddTestXmlHandlerP13wxXmlResource(ctypes.c_void_p(addr))
|
||||||
|
#test.AddTestXmlHandler(ctypes.c_void_p(addr))
|
||||||
res.Load('memory:xxx.xrc')
|
res.Load('memory:xxx.xrc')
|
||||||
try:
|
try:
|
||||||
if xxx.__class__ == xxxFrame:
|
if xxx.__class__ == xxxFrame:
|
||||||
|
@@ -1365,6 +1365,8 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
xxxMenuBar, xxxMenu, xxxToolBar,
|
xxxMenuBar, xxxMenu, xxxToolBar,
|
||||||
xxxWizard, xxxBitmap, xxxIcon]:
|
xxxWizard, xxxBitmap, xxxIcon]:
|
||||||
self.maxIDs[cl] = 0
|
self.maxIDs[cl] = 0
|
||||||
|
# Handlers
|
||||||
|
clearHandlers()
|
||||||
|
|
||||||
def SetModified(self, state=True):
|
def SetModified(self, state=True):
|
||||||
self.modified = state
|
self.modified = state
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from globals import *
|
from globals import *
|
||||||
from params import *
|
from params import *
|
||||||
|
import traceback, types
|
||||||
|
|
||||||
# Base class for interface parameter classes
|
# Base class for interface parameter classes
|
||||||
class xxxNode:
|
class xxxNode:
|
||||||
@@ -918,10 +919,69 @@ class xxxUnknown(xxxObject):
|
|||||||
################################################################################
|
################################################################################
|
||||||
# Comment
|
# Comment
|
||||||
|
|
||||||
|
_handlers = []
|
||||||
|
_CFuncPtr = None
|
||||||
|
|
||||||
|
def register(hndlr):
|
||||||
|
if _CFuncPtr and isinstance(hndlr, _CFuncPtr):
|
||||||
|
_handlers.append(hndlr)
|
||||||
|
return
|
||||||
|
if not isinstance(hndlr, type):
|
||||||
|
wx.LogError('handler is not a type: %s' % hndlr)
|
||||||
|
elif not issubclass(hndlr, wx.xrc.XmlResourceHandler):
|
||||||
|
wx.LogError('handler is not a XmlResourceHandler: %s' % hndlr)
|
||||||
|
else:
|
||||||
|
_handlers.append(hndlr)
|
||||||
|
|
||||||
|
def load_dl(path, localname=''):
|
||||||
|
try:
|
||||||
|
import ctypes
|
||||||
|
global _CFuncPtr
|
||||||
|
_CFuncPtr = ctypes._CFuncPtr
|
||||||
|
except ImportError:
|
||||||
|
wx.LogError('ctypes module not found')
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
dl = ctypes.CDLL(path)
|
||||||
|
if not localname:
|
||||||
|
localname = os.path.basename(os.path.splitext(dl._name)[0])
|
||||||
|
globals()[localname] = dl
|
||||||
|
except:
|
||||||
|
wx.LogError('error loading dynamic library: %s', path)
|
||||||
|
print traceback.print_exc()
|
||||||
|
|
||||||
|
# Called when creating test window
|
||||||
|
def addHandlers(res):
|
||||||
|
for h in _handlers:
|
||||||
|
if _CFuncPtr and isinstance(h, _CFuncPtr):
|
||||||
|
try:
|
||||||
|
apply(h, ())
|
||||||
|
except:
|
||||||
|
wx.LogError('error calling DL func: "%s"' % h)
|
||||||
|
print traceback.print_exc()
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
res.AddHandler(apply(h, ()))
|
||||||
|
except:
|
||||||
|
wx.LogError('error adding XmlHandler: "%s"' % h)
|
||||||
|
print traceback.print_exc()
|
||||||
|
|
||||||
|
def clearHandlers():
|
||||||
|
global _handlers
|
||||||
|
_handlers = []
|
||||||
|
|
||||||
class xxxParamComment(xxxParam):
|
class xxxParamComment(xxxParam):
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
xxxNode.__init__(self, node)
|
xxxNode.__init__(self, node)
|
||||||
self.textNode = node
|
self.textNode = node
|
||||||
|
# Parse "pragma" comments
|
||||||
|
if node.data and node.data[0] == '%':
|
||||||
|
try:
|
||||||
|
code = node.data[1:]
|
||||||
|
exec code in globals()
|
||||||
|
except:
|
||||||
|
wx.LogError('exec error: "%s"' % code)
|
||||||
|
print traceback.print_exc()
|
||||||
|
|
||||||
class xxxComment(xxxObject):
|
class xxxComment(xxxObject):
|
||||||
hasStyle = hasName = False
|
hasStyle = hasName = False
|
||||||
|
Reference in New Issue
Block a user