]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Layoutf.py
Added PyPlot
[wxWidgets.git] / wxPython / demo / Layoutf.py
CommitLineData
8fa876ca
RD
1# 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4# o Controls now use dynamic IDs instead of hardcoded IDs.
5#
cf694132 6
8fa876ca
RD
7import wx
8import wx.lib.layoutf as layoutf
cf694132
RD
9
10#---------------------------------------------------------------------------
11
8fa876ca
RD
12ID_Button = wx.NewId()
13
14#---------------------------------------------------------------------------
15
16class TestLayoutf(wx.Panel):
cf694132 17 def __init__(self, parent):
8fa876ca 18 wx.Panel.__init__(self, parent, -1)
cf694132 19
1e4a197e 20 self.SetAutoLayout(True)
372bde9b 21 self.Bind(wx.EVT_BUTTON, self.OnButton, id=ID_Button)
cf694132 22
8fa876ca
RD
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,))
27 )
cf694132 28
8fa876ca
RD
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))
33 )
cf694132 34
8fa876ca
RD
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))
39 )
cf694132 40
8fa876ca
RD
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,)))
cf694132 43
8fa876ca
RD
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,)))
cf694132 46
8fa876ca
RD
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))
51 )
cf694132 52
8fa876ca
RD
53 b = wx.Button(self.panelC, ID_Button, ' Panel C ')
54 b.SetConstraints(layoutf.Layoutf('t_#1;l>#1;h*;w*', (self.panelD,)))
cf694132 55
8fa876ca 56 wx.StaticText(self.panelD, -1, "Panel D", (4, 4)).SetBackgroundColour(wx.GREEN)
cf694132
RD
57
58 def OnButton(self, event):
8fa876ca 59 wx.Bell()
cf694132
RD
60
61
62
63#---------------------------------------------------------------------------
64
65def runTest(frame, nb, log):
66 win = TestLayoutf(nb)
67 return win
68
69#---------------------------------------------------------------------------
70
8fa876ca 71overview = layoutf.Layoutf.__doc__
1fded56b
RD
72
73if __name__ == '__main__':
74 import sys,os
75 import run
76 run.main(['', os.path.basename(sys.argv[0])])
77