O'Reilly logo

wxPython 2.8 Application Development Cookbook by Cody Precord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding inheritance limitations

wxPython is a wrapper around the wxWidgets C++ framework. This relationship means that inside most wxPython objects there is a C++ object. Because of this, methods that belong to wxPython classes cannot always be overridden in the same way as they can with a normal Python object.

To demonstrate this behavior, this recipe will show how to create a class that will automatically add its children windows to its Sizer layout. This will be contrasted to a class that does not expose its virtual methods to the Python layer of the class.

How to do it...

To demonstrate the difference in overriding methods, we will create two similar classes first starting with one that derives from the standard Panel class:

import wx class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required