From: Michael S. <mik...@ya...> - 2005-04-28 21:40:59
Attachments:
testLayoutManagers.py
testLayoutManagers.rsrc.py
|
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 |
From: Alex T. <al...@tw...> - 2005-04-30 14:30:41
|
Michael Sorich wrote: >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 > too simple ... >2) Relative anchors > still too simple .... >3) Advanced anchors > getting interesting ... >I would be interested in comments and examples where >these layout managers do and do not work well. > > Only talking about Advanced anchors - the others really do hit their limits very quickly. 1. In the example you sent out, try to add a "Button 3" mid-way between B1 and B2. I'd like B3 to remain mid-way between them as the window width is varied. Can't do that currently. Would be easy enough to add a "fixed-size" flag, so that it could be anchored to L and R, position calculated as it is currently - but then adjusted to keep the size unchanged. (i.e. it would find the right place to grow into - but not grow, leaving space on each side). 2. (This may really be 1a :-) In the devx article you mentioned, they had a static text (label) beside a text area; as the text area grows, the label should "float" to remain half-way up the side. 3. Mix of expanding and non-expanding components. label 1: [.Txtfld 1...] label 2: [.Txtfld 2...] label 3: [.......tf3.] where you want the labels to stay fixed-width, and the fields to grow to fill the available width. (I don't think there's a way to do just that). 4. Interference. Extend the last case ... [button 1 across here about this long] label 1: [.Txtfld 1...] label 2: [.Txtfld 2...] label 3: [.......tf3.] where you want the labels to stay fixed-width, and the fields to grow to fill the available width. The edges of button1 become partition edges - and so change the growth patterns of the textfields 1 and 2. If you put the button way up at the top of the background, and the fields way at the bottom - with a lot of other stuff in between, it would be very hard to understand what's going on ... -- Alex. -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.10.4 - Release Date: 27/04/2005 |