From: Michael S. <mik...@ya...> - 2005-04-28 21:40:59
|
I have written some code to reposition/resize components with changes in Background (wxFrame) size. There are 3 options. The only requirement for each is that the anchors property is set for each component these indicate how the component should move/size with respect to its environment. I have attached a simple example GUI that can be run to demonstrate the 3 layout managers. The layout manager and anchors for each component can be changed in MyBackground.on_initialize. 1) Simple anchors are used in Delphi and .Net Forms. See links below for description of this http://euler.aero.iitb.ac.in/docs/Programming/wxPython-2.5.2.8/docs/api/wx.lib.anchors.LayoutAnchors-class.html http://www.devx.com/dotnet/Article/6964/0/page/3 This layout manager does not work well if there is more than one component to be resized in each direction. Thus the example attached is not a good example for this layout manager. By limiting the number of components that resize, this method will work Eg set tree anchors to TRB (Top-Right-Bottom -> only height change), and TextArea anchors to LT (Left-Top -> no resizing). 2) Relative anchors are very similar to simple anchors. However, components are constrained to be a percentage distance to the containers edge (relative to containers width/height). Ie instead of setting a distance of 10 pixels, it is set to 10% (for a container of width 100 pixels). This layout manager is able to able to deal with multiple resizable components. However, the distances between all components changes as the window resizes. If the resizable components do not take up the majority of the window space, the increased spacing between components as the window grows may look strange. 3) Advanced anchors allow for multiple resizable components and absolute spacing by dividing the window into a grid (based on position/size of all resizable components) and the components are anchored relative to the closest grid line in each direction. The grid resizes with the window and the components are resized to maintain their distance constraints to the grid lines. Each column/row in the grid has a different weight which determines the extent that the row/col size changes with container size. The col/row weights are automatically calculated (there are multiple options for how this can be automatically calculated and obviously the option to manually set the weights). The Background has a method showPartitions(True) that can be used to show the grid lines. I would be interested in comments and examples where these layout managers do and do not work well. Michael Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com |