]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Layoutf.py
1 # 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
4 # o Controls now use dynamic IDs instead of hardcoded IDs.
8 import wx
.lib
.layoutf
as layoutf
10 #---------------------------------------------------------------------------
12 ID_Button
= wx
.NewId()
14 #---------------------------------------------------------------------------
16 class TestLayoutf(wx
.Panel
):
17 def __init__(self
, parent
):
18 wx
.Panel
.__init
__(self
, parent
, -1)
20 self
.SetAutoLayout(True)
21 self
.Bind(EVT_BUTTON
, self
.OnButton
, id=ID_Button
)
23 self
.panelA
= wx
.Window(self
, -1, style
=wx
.SIMPLE_BORDER
)
24 self
.panelA
.SetBackgroundColour(wx
.BLUE
)
25 self
.panelA
.SetConstraints(
26 layoutf
.Layoutf('t=t10#1;l=l10#1;b=b10#1;r%r50#1',(self
,))
29 self
.panelB
= wx
.Window(self
, -1, style
=wx
.SIMPLE_BORDER
)
30 self
.panelB
.SetBackgroundColour(wx
.RED
)
31 self
.panelB
.SetConstraints(
32 layoutf
.Layoutf('t=t10#1;r=r10#1;b%b30#1;l>10#2', (self
,self
.panelA
))
35 self
.panelC
= wx
.Window(self
, -1, style
=wx
.SIMPLE_BORDER
)
36 self
.panelC
.SetBackgroundColour(wx
.WHITE
)
37 self
.panelC
.SetConstraints(
38 layoutf
.Layoutf('t_10#3;r=r10#1;b=b10#1;l>10#2', (self
,self
.panelA
,self
.panelB
))
41 b
= wx
.Button(self
.panelA
, ID_Button
, ' Panel A ')
42 b
.SetConstraints(layoutf
.Layoutf('X=X#1;Y=Y#1;h*;w%w50#1', (self
.panelA
,)))
44 b
= wx
.Button(self
.panelB
, ID_Button
, ' Panel B ')
45 b
.SetConstraints(layoutf
.Layoutf('t=t2#1;r=r4#1;h*;w*', (self
.panelB
,)))
47 self
.panelD
= wx
.Window(self
.panelC
, -1, style
=wx
.SIMPLE_BORDER
)
48 self
.panelD
.SetBackgroundColour(wx
.GREEN
)
49 self
.panelD
.SetConstraints(
50 layoutf
.Layoutf('b%h50#1;r%w50#1;h=h#2;w=w#2', (self
.panelC
, b
))
53 b
= wx
.Button(self
.panelC
, ID_Button
, ' Panel C ')
54 b
.SetConstraints(layoutf
.Layoutf('t_#1;l>#1;h*;w*', (self
.panelD
,)))
56 wx
.StaticText(self
.panelD
, -1, "Panel D", (4, 4)).SetBackgroundColour(wx
.GREEN
)
58 def OnButton(self
, event
):
63 #---------------------------------------------------------------------------
65 def runTest(frame
, nb
, log
):
69 #---------------------------------------------------------------------------
71 overview
= layoutf
.Layoutf
.__doc
__
73 if __name__
== '__main__':
76 run
.main(['', os
.path
.basename(sys
.argv
[0])])