Fair enough, especially since I just hit "Send" too quick a few moments ago and sent the demo archive to the list.
In addition to what I said there, here's a quick overview. I've made a subclass of Panel currently called "FlexPanel" which, instead of using sizers, repositions its children in its resize event. How does it know where to move them? Well, each child can have zero or more "position terms" associated with it. Each term has an identifier which must be one of the following:
posLeft posRight posWidth posMidX
posTop posBottom posHeight posMidY
Then it has an expression, which is stored and re-evaluated whenever the panel needs to be laid out (for example, when it is resized). The expression is evaluated with eval() in a context that defines the following variables:
self: a position provider for the panel containing this item [1]
parent: synonym for 'self'
me: a position provider for the item being positioned [1]
<item name>: a position provider for the named item within the parent
gap: standard (horizontal or vertical as appropriate) gap between controls
halfgap: equal to gap/2
labelgap: standard gap between a label and the control it's labelling [2]
leftMargin: standard gutter on left side of window [2]
rightMargin: standard gutter on right side of window [2]
topMargin: standard gutter on top side of window [3]
bottomMargin: standard gutter on bottom side of window [3]
maxWidth: function that returns the maximum width of the given items
maxHeight: function that returns the maximum height of the given items
Notes: [1] A "position provider" is a wrapper for a wx.Window that provides
the following attributes: left, right, width, midX, top, bottom, height, midY.
In addition, you can access any other attribute the object would normally
have (such as Name).
[2] These variables are defined only for horizontal position terms.
[3] These variables are defined only for vertical position terms.
Since the position terms are expressions, it is perfectly valid to specify a
calculation such as 'parent.midX / 2' (without the quotes). So basically this
allows you to set the position or width of anything, relative to anything else
(including some common platform-specific values like the margins and the gap
between controls).
You can set up these things manually, but I also made a simple parser that takes
a text file containing stuff like this...
# Create a couple of labels at the top of the panel, one
# on the left side, and the other on the right.
label1: wx.StaticText
label: "Left Label"
posTop: topMargin
posLeft: leftMargin
label2: wx.StaticText
label: "Right-Aligned Label"
posTop: topMargin
posRight: rightMargin
# Add a big expanding button, centered vertically, and extending
# from 140 pixels on the left to 40 pixels from the right edge.
stretchBtn: wx.Button
label: "Stretchy"
posMidY: parent.midY
posLeft: 140
posRight: parent.right - 40
bind EVT_BUTTON: self.OnClick
...and sets it all up for you (including binding the events, if you include one or more "bind" specifiers). (More examples are included in the "demo.txt" file in the archive.)
So that's the big picture -- I've found defining layouts in this format to be quick and easy even without a visual layout builder, but the long-term intent of the design is to allow such a builder to be bolted on neatly in the future.
Cheers,
- Joe
···
On Nov 19, 2008, at 2:25 PM, Christopher Barker wrote:
If there is anyone here who has substantial experience in wxPython, but has occasionally felt that there should be an easier way to manage layouts,
That would be a good fraction of this list
I'd start the discussion here -- if it gets to be too much, we can move it off-list then.