How to use AddSubclassFactory from wxPython?

I can not find any examples online on how to use this method. I think this may be what I will use. Can someone provide me an example of how to use this method?

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

+6
source share
1 answer

Based on the source code, I believe that it will be so.

Source code: 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) 

So you can see that it is looking for an object of type XmlSubclassFactory. From the documentation (http://wxpython.org/docs/api/wx.xrc.XmlSubclassFactory-class.html) we find ...

 XmlSubclassFactory __init__(self) 

We see that the constructor for XmlSubClassFactory takes no arguments. Therefore, we create an XmlSubclassFactory object and create a resource to add SubClassFactory to.

 import wx from wx import xrc scf = xrc.XmlSubClassFactory() resource = xrc.XmlResource("resource.xrc") resource.AddSubclassFactory(scf) 

Unfortunately, I could not find a Python example. However, I think the Perl analogue is pretty close. From http://permalink.gmane.org/gmane.comp.lang.perl.wxperl/477

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

This is very similar to what we are doing. So, between reading the source code and this example, I think the snippet is a good place to start. Good luck

+4
source

Source: https://habr.com/ru/post/921811/


All Articles