One or multiple xmlresource handlers?
Roman Rolinsky
genericsoma at gmail.com
Mon Jul 2 13:31:09 PDT 2007
Gre7g Luterman <hafeliel <at> yahoo.com> writes:
>
> Aren't these custom controls just subclasses of
> existing controls (such as a wxPanel)? If so, save
> yourself some work and just define it as a subclass.
>
> Gre7g
>
> --- Jorgen Bodde <jorgen.maillist <at> gmail.com> wrote:
>
> > Hi all,
> >
> > I have two custom controls I want to embed in XRC.
> > My question is, is
> > it better to create two handler classes? Or can I
> > use one handler
> > class (derived from xrc.XmlResourceHandler) ?
> >
> > I'm asking from a performance point of view, since
> > every class name is
> > 'asked' to the handler if it can handle it or not..
> >
> > With regards,
> > - Jorgen
Custom controls are not necessarily subclasses of existing controls, they can be
derived directly from wxWindow for example.
One handler should be better, because it will avoid the overhead of calling
python from C++, which must be greater than the time spent in Python's if/else
(or a dictionary/hash table lookup, or whatever you use). Note that the time
difference exists only for custom controls, provided you use AddHandler - your
handlers will never be called for the standard controls. So unless you have many
custom controls, the performance difference will be negligible.
XRC library uses common handlers for related classes such as wxMenu/wxMenuItem.
Roman
More information about the wxpython-users
mailing list