【问题标题】:How to use AddSubclassFactory from wxPython?如何使用 wxPython 中的 AddSubclassFactory?
【发布时间】:2012-07-29 20:21:29
【问题描述】:

我在网上找不到任何个关于如何使用此方法的示例。我认为这可能是我会使用的东西。谁能给我一个如何使用这个方法的例子?

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

【问题讨论】:

    标签: python wxpython wxwidgets wxruby


    【解决方案1】:

    根据源代码,我相信你会这样做。

    源代码: 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)我们发现...

    XmlSubclassFactory  __init__(self)
    

    我们可以看到 XmlSubClassFactory 的构造函数没有参数。所以我们创建一个 XmlSubclassFactory 的对象,并创建一个资源来添加 SubClassFactory。

    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
    

    这与我们正在做的非常相似。所以在阅读源代码和那个例子之间,我相信 sn-p 是一个很好的起点。祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 2019-09-11
      • 2011-10-31
      • 2014-04-11
      • 1970-01-01
      相关资源
      最近更新 更多