From: Michael S. <mik...@ya...> - 2005-04-18 19:42:30
|
Hi, I have written some simple code to allow for anchoring of components to edges of containers. This corresponds fairly closely to a past discussion on the list http://aspn.activestate.com/ASPN/Mail/Message/pythoncard/1183899. Attached are a few files that can be run to demonstrate the concept. The code is very short and simple. I have written it based on PythonCard v0.8.1 testAnchors.py has all the layout code included in the file. You should be able to run this application without any changes to the PythonCard installation. If you update model.py, widget.py, and propertyEditor.py in your PythonCard distribution, you will be able to get testAnchors2.py to run. This should display the same example application. The anchors variable is now stored in the rsrc file (and can be set/viewed in the resource editor). The testAnchors2.py file is now nothing more than the standard file automatically created with a new application. You should be able to test your own examples simply make a new application and set the anchors property in the property editor (there should be a list of options with default of LT ie left and top- and thus if you dont change the property it will continue to act as it did before this update). Alternatively, load an existing rsrc file and alter the anchors property and save. testAnchors.py is an example that demonstrates the limitations of this approach. Components set to expand with an expanding container are greedy their increase in size is equivalent to the increase in size of the container. Hence when there are multiple components that are to change size this may cause problems. A mechanism of sharing the container size change between multiple components is necessary to deal with this. I am unsure what the simplest way of doing this is. I think it is rather confusing to set the sharing on a component by component basis. A simpler approach may be to partition the container into segments (by rows or columns), with a simple mechanism for sharing the container size changes. The components would then reference the sub containers (using anchors). I hope this is useful. If so, feel free to use the code under the same license as pythoncard. Michael Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com |