]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Layoutf.py
Applied patch [ 827011 ] Event-based processing of item tooltips in wxTreeCtrl
[wxWidgets.git] / wxPython / demo / Layoutf.py
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 #
6
7 import wx
8 import wx.lib.layoutf as layoutf
9
10 #---------------------------------------------------------------------------
11
12 ID_Button = wx.NewId()
13
14 #---------------------------------------------------------------------------
15
16 class TestLayoutf(wx.Panel):
17 def __init__(self, parent):
18 wx.Panel.__init__(self, parent, -1)
19
20 self.SetAutoLayout(True)
21 self.Bind(EVT_BUTTON, self.OnButton, id=ID_Button)
22
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 )
28
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 )
34
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 )
40
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,)))
43
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,)))
46
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 )
52
53 b = wx.Button(self.panelC, ID_Button, ' Panel C ')
54 b.SetConstraints(layoutf.Layoutf('t_#1;l>#1;h*;w*', (self.panelD,)))
55
56 wx.StaticText(self.panelD, -1, "Panel D", (4, 4)).SetBackgroundColour(wx.GREEN)
57
58 def OnButton(self, event):
59 wx.Bell()
60
61
62
63 #---------------------------------------------------------------------------
64
65 def runTest(frame, nb, log):
66 win = TestLayoutf(nb)
67 return win
68
69 #---------------------------------------------------------------------------
70
71 overview = layoutf.Layoutf.__doc__
72
73 if __name__ == '__main__':
74 import sys,os
75 import run
76 run.main(['', os.path.basename(sys.argv[0])])
77