wxGlade wxPython and custom components

A reminder to me of how to use custom components in a wxGlade Project.
I had a Panel which contained controls for a Matplotlib Project. The panel contained the plotting surface and some combo boxes to set parameters. I wanted to use this on multiple packages of a notebook to present different data views. This was a good canditiate for being re-used and subclassed. But how to to do that using wxGlade…..

This assumes a component based upon a Panel called a nineGraafTabPage_M
Where the component is first used
Properties->Common->Class nineGraafTabPage_M
Properties->Common->BaseClasse(s) tick and set to wx.Panel (not NOT wxPanel)

How to reuse the Component

Now if we wish to reuse that panel somewhere else, for example on a notebook page. Then on the page you wish to use it. First of all inset a normal panel. Then
Properties->Common->Class NewNameWhatever
Properties->Common->BaseClasse(s) tick and set to nineGraafTabPage_M
Then also add on
Properties->Common->Code tick Extra code for this widget
and in the extra code section
from nineGraafTabPage_M import nineGraafTabPage_M
(important follow this with a carriage return)
Then click on the add properties button and set a property of id with a value of -1

General

In the application property page also tick
Code Generation Separate file for each class

This entry was posted in coding, computing, python, wxGlade and tagged , . Bookmark the permalink.

Comments are closed.