]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxScrolledPanel.py
1 # 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
5 # 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o scrolledpanel lib needs wx update
11 import wx
.lib
.scrolledpanel
as scrolled
13 #----------------------------------------------------------------------
15 text
= "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen"
18 class TestPanel(scrolled
.wxScrolledPanel
):
19 def __init__(self
, parent
, log
):
21 scrolled
.wxScrolledPanel
.__init
__(self
, parent
, -1)
23 vbox
= wx
.BoxSizer(wx
.VERTICAL
)
24 desc
= wx
.StaticText(self
, -1,
25 "wxScrolledPanel extends wxScrolledWindow, adding all "
26 "the necessary bits to set up scroll handling for you.\n\n"
27 "Here are three fixed size examples of its use. The "
28 "demo panel for this sample is also using it -- the \nwxStaticLine"
29 "below is intentionally made too long so a scrollbar will be "
32 desc
.SetForegroundColour("Blue")
33 vbox
.Add(desc
, 0, wx
.ALIGN_LEFT|wx
.ALL
, 5)
34 vbox
.Add(wx
.StaticLine(self
, -1, size
=(1024,-1)), 0, wx
.ALL
, 5)
39 panel1
= scrolled
.wxScrolledPanel(self
, -1, size
=(120,300),
40 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
41 fgs1
= wx
.FlexGridSizer(cols
=2, vgap
=4, hgap
=4)
44 label
= wx
.StaticText(panel1
, -1, word
+":")
45 tc
= wx
.TextCtrl(panel1
, -1, word
, size
=(50,-1))
46 fgs1
.Add(label
, flag
=wx
.ALIGN_RIGHT | wx
.ALIGN_CENTER_VERTICAL
)
47 fgs1
.Add(tc
, flag
=wx
.EXPAND|wx
.RIGHT
, border
=25)
49 panel1
.SetSizer( fgs1
)
50 panel1
.SetAutoLayout(1)
51 panel1
.SetupScrolling( scroll_x
=False )
53 panel2
= scrolled
.wxScrolledPanel(self
, -1, size
=(350, 40),
54 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
55 panel3
= scrolled
.wxScrolledPanel(self
, -1, size
=(200,100),
56 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
58 fgs2
= wx
.FlexGridSizer(cols
=25, vgap
=4, hgap
=4)
59 fgs3
= wx
.FlexGridSizer(cols
=5, vgap
=4, hgap
=4)
61 for i
in range(len(words
)):
64 label2
= wx
.StaticText(panel2
, -1, word
)
65 fgs2
.Add(label2
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
66 label3
= wx
.StaticText(panel3
, -1, word
)
67 fgs3
.Add(label3
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
69 tc2
= wx
.TextCtrl(panel2
, -1, word
, size
=(50,-1))
70 fgs2
.Add(tc2
, flag
=wx
.LEFT
, border
=5)
71 tc3
= wx
.TextCtrl(panel3
, -1, word
)
72 fgs3
.Add(tc3
, flag
=wx
.LEFT
, border
=5)
74 panel2
.SetSizer( fgs2
)
75 panel2
.SetAutoLayout(1)
76 panel2
.SetupScrolling(scroll_y
= False)
78 panel3
.SetSizer( fgs3
)
79 panel3
.SetAutoLayout(1)
80 panel3
.SetupScrolling()
82 hbox
= wx
.BoxSizer(wx
.HORIZONTAL
)
87 vbox2
= wx
.BoxSizer(wx
.VERTICAL
)
95 vbox
.AddSizer(hbox
, 0)
101 #----------------------------------------------------------------------
104 def runTest(frame
, nb
, log
):
105 win
= TestPanel(nb
, log
)
108 #----------------------------------------------------------------------
112 overview
= """<html><body>
113 wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
114 providing automatic scrollbar and scrolling behavior and the tab traversal
115 mangement that wxScrolledWindow lacks.
120 if __name__
== '__main__':
123 run
.main(['', os
.path
.basename(sys
.argv
[0])])