From: Hugh K. <ma...@hu...> - 2007-11-03 22:56:55
|
I found PythonCard some time ago while looking for a way to write 'real programmes' for Windows. Its simplicity and logical structure appealed to me. Through it I have learnt a huge amount about both Python and wxWidgets. In particular the ability to adapt, amend and extend the tools is very satisfying. Like others I found the inability to use sizers easily was a drawback. Not so much of a drawback as to make me want to learn C++ and code in wxWidgets, or to give up PythonCard, but at the same time I objected to mixing programmatic generation of sizers into my code - it is also a hard way to learn. Inspiration for a solution came with Alex Tweedly's simplesizer and I set off with the aim of making sizers work for PythonCard while maintaining what seem to be its two key characteristics: the separation of layout and processing, and the use of visual drag-and-drop tools for layout. A secondary aim was to develop the routines in a way which did not break existing tools or code. I now have something which is firmly an alpha version and a work in progress, but it does work in several regards. I'd be happy to share my code for comment and improvement but the mailing list rejected the zip file (even if it was only 106Kb). So I'd be glad if someone could explain how to get round that. The elements are: (a) additions to the existing Layout Editor to create a visual Sizer Editor which manipulates sizers and allows components to be dropped into them and re-arranged at will; the effect of different settings can be seen immediately; (b) the final sizer details are saved into the current .rsrc.py file; (b) a short routine, called autoSizer, which processes the sizer data in the .rsrc file when a main application is initialized. The routines handle BoxSizers, GridSizers and StaticBoxSizers; FlexGridSizers are implemented but I am not 100% convinced I've got them right. The biggest omission is the ability to override manually the sizer engine's calculation of minimum dimensions for components. There is an option to ease the conversion of existing .rsrc.py layouts to a sizer-based format. A menu option creates a single vertical sizer containing all the components in the .rsrc file (effectively an on-screen list). You can then define your desired sizer configuration and drag and drop the components into the right places. Eventually the temporary vertical sizer can be deleted when it is empty. Slightly tedious but it works and it beats re-typing all your components. I have had trouble with setting minimum sizes, so I've parked that for now. I have also yet to master re-drawing the screen properly, dealing with the sizing handles when they get misplaced, and the impact of the MenuBar on the editor display. Nor have I tested the interaction of my sizer-based solutions with all the elements of Layout Editor, especially multiple selections. The GridBagSizer is a joy to come, as are global and multiple edits of sizers, drag-and-drop in the sizer tree etc, etc! Thanks, Hugh Kernohan |