wxPython: An Introduction to XRC

Have you ever wondered if you could create a wxPython program using XML? Well, I never did either, but there is a way and its name is XRC. In fact, wxPython comes with an editor called XRCed that you can use to layout your GUI and generate the XML code with. In this article, we'll give you a quick walk-through of XRC and how to use it to create a couple GUI skeletons. We will look at two examples that use only XRC controls and then a third that mixes in some additional non-XRC widgets.

Creating a Login Screen with XRC

A common dialog that we often see is a login dialog. I used XRCed to create the following XML code:




wxVERTICAL


wxALL
5



wxALL
5



wxALL|wxALIGN_CENTRE
5


wxALL|wxALIGN_CENTRE
5

2 3
4
2

5