/ Hathaway Weblog / XRCed

Shane :: Python :: October 22, 2004 # XRCed

Most GUI builders make you place components in fixed positions with fixed sizes, which is fine until somebody displays your dialog with a large font or your dialog needs to be translated to another language. GUI toolkits include "sizers" or "layout managers" which place components automatically, but most GUI builders either don't provide access to those features or integrate them badly. Not XRCed!

XRCed, included with wxPython, encourages the use of sizers by providing no WYSIWYG interface at all. Instead, you edit a tree of windows, containers, sizers, and controls. There is a preview window, but all editing happens in the tree control and a property window. Unlike editing XML in a text editor, this method informs you of your options as you're editing, and unlike WYSIWYG GUI building, this method makes you specify constraints rather than constants.

I sat down with XRCed two days ago. I found it difficult to use at first, but I learned that XRCed only reflects the quirks in wxWidgets. For instance, if you want a margin between the edges of the dialog and the controls inside, you have to put all the controls in a panel, set a border width for the panel, and enable the flag wxALL (which means "all edges should use the border width".) If you want the large panel to expand with the dialog, you have to put it inside a FlexGridSizer and tell the grid to auto-expand the single column and row. If you want to specify the color of the dialog, it seems that you have to put your main sizer in a FlexGridSizer in a Panel in a FlexGridSizer, then set up the border on your main sizer rather than the panel. And if you want a panel that inherits the color of its parent, you actually want a sizer instead of a panel.

I have used wxPython occasionally over the past three years, and until now I could not figure out how to convince the sizers to behave the way I want them to. Now I finally understand that the simple sizer model is quite far behind CSS. A "StyleSheetSizer" could be very cool: just put all your components in a tree then specify layout constraints in a text file with CSS syntax.

But for now, anyone who uses wxPython or wxWidgets should definitely try XRCed. Once I understood the wxWidgets quirks, it became quite easy to achieve the layouts I wanted. It cleaned up my Python code a lot.

Comments

Waldemar Osuch (October 23, 2004 00:37)
If you like XRCed you should also look at wxGlade. wxGlade work on similar layout principle but generates fairly clean Python code instad of xml.

No further comments may be added.

Click below to fill in the scripture reference.
Your browser is not able to display the scripture fill-in program. To see it, enable Javascript or use Mozilla 1.0 or better.
For behold, I, God, have suffered these things for all, that they might not suffer if they would repent; But if they would not repent they must suffer even as I; Which suffering caused myself, even God, the greatest of all, to tremble because of pain, and to bleed at every pore, and to suffer both body and spirit--and would that I might not drink the bitter cup, and shrink-- Nevertheless, glory be to the Father, and I partook and finished my preparations unto the children of men.

Church: lds scriptures provident games pearls kzion shiblon film chancellor gateway cumorah byutv happiness nephi
Zope: freezope org com zen labs newbies zettai warnes
Python: home pyzine daily icanprogram
Genealogy: cyndi
Weblogs: jeffrey paul jon joel another-shane guido barry jeremy windley chrism zac
News: quakes lwn dc weather deseret zeitgeist softwarelivre
Zaurus: software developer
Tech: tango spintronics thin
Semantic: aaron sean
Reference: css rdf html4 javascript geckodom iecss emacs phrases acronyms
Reverse: advogato slashdot
Misc: gimp-savvy directory soda jokes shouldexist pdphoto