如何使用wxPython中的AddSubclassFactory?

2024-10-04 11:26:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我在网上找不到任何关于如何使用这种方法的例子。我想这可能是我会用到的东西。有人能给我举一个如何使用这个方法的例子吗?在

http://wxpython.org/docs/api/wx.xrc.XmlResource-class.html


Tags: 方法orgapihttpdocshtmlwxpythonclass
1条回答
网友
1楼 · 发布于 2024-10-04 11:26:09

基于源代码,我相信这就是你应该做的。在

源代码: http://wxwidgets2.8.sourcearchive.com/documentation/2.8.7.1/classxrc_1_1XmlResource_4a0466d7ef7ac98ef7a9b8135a0c9339.html

def AddSubclassFactory(*args, **kwargs):
    """AddSubclassFactory(XmlSubclassFactory factory)"""
    return _xrc.XmlResource_AddSubclassFactory(*args, **kwargs)

因此,您可以看到它正在查找XmlSubclassFactory类型的对象。从文档中(http://wxpython.org/docs/api/wx.xrc.XmlSubclassFactory-class.html)我们发现。。。在

^{pr2}$

我们可以看到XmlSubClassFactory的构造函数没有参数。因此,我们创建了一个XmlSubclassFactory对象,并创建了一个将子类工厂添加到其中的资源。在

import wx
from wx import xrc

scf = xrc.XmlSubClassFactory()
resource = xrc.XmlResource("resource.xrc")
resource.AddSubclassFactory(scf)

不幸的是,我找不到Python示例。但是,我认为Perl模拟非常接近。从http://permalink.gmane.org/gmane.comp.lang.perl.wxperl/477

Wx::XmlResource::AddSubclassFactory( MyFactory->new ); // perl

这和我们正在做的很相似。我相信代码片段和源代码之间是一个很好的开始。祝你好运!在

相关问题 更多 >