]>
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
9 # 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net)
11 # o lib updated, all is well.
15 import wx
.lib
.scrolledpanel
as scrolled
17 #----------------------------------------------------------------------
19 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"
22 class TestPanel(scrolled
.wxScrolledPanel
):
23 def __init__(self
, parent
, log
):
25 scrolled
.wxScrolledPanel
.__init
__(self
, parent
, -1)
27 vbox
= wx
.BoxSizer(wx
.VERTICAL
)
28 desc
= wx
.StaticText(self
, -1,
29 "wxScrolledPanel extends wxScrolledWindow, adding all "
30 "the necessary bits to set up scroll handling for you.\n\n"
31 "Here are three fixed size examples of its use. The "
32 "demo panel for this sample is also using it -- the \nwxStaticLine"
33 "below is intentionally made too long so a scrollbar will be "
36 desc
.SetForegroundColour("Blue")
37 vbox
.Add(desc
, 0, wx
.ALIGN_LEFT|wx
.ALL
, 5)
38 vbox
.Add(wx
.StaticLine(self
, -1, size
=(1024,-1)), 0, wx
.ALL
, 5)
43 panel1
= scrolled
.wxScrolledPanel(self
, -1, size
=(120,300),
44 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
45 fgs1
= wx
.FlexGridSizer(cols
=2, vgap
=4, hgap
=4)
48 label
= wx
.StaticText(panel1
, -1, word
+":")
49 tc
= wx
.TextCtrl(panel1
, -1, word
, size
=(50,-1))
50 fgs1
.Add(label
, flag
=wx
.ALIGN_RIGHT | wx
.ALIGN_CENTER_VERTICAL
)
51 fgs1
.Add(tc
, flag
=wx
.EXPAND|wx
.RIGHT
, border
=25)
53 panel1
.SetSizer( fgs1
)
54 panel1
.SetAutoLayout(1)
55 panel1
.SetupScrolling( scroll_x
=False )
57 panel2
= scrolled
.wxScrolledPanel(self
, -1, size
=(350, 40),
58 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
59 panel3
= scrolled
.wxScrolledPanel(self
, -1, size
=(200,100),
60 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
62 fgs2
= wx
.FlexGridSizer(cols
=25, vgap
=4, hgap
=4)
63 fgs3
= wx
.FlexGridSizer(cols
=5, vgap
=4, hgap
=4)
65 for i
in range(len(words
)):
68 label2
= wx
.StaticText(panel2
, -1, word
)
69 fgs2
.Add(label2
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
70 label3
= wx
.StaticText(panel3
, -1, word
)
71 fgs3
.Add(label3
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
73 tc2
= wx
.TextCtrl(panel2
, -1, word
, size
=(50,-1))
74 fgs2
.Add(tc2
, flag
=wx
.LEFT
, border
=5)
75 tc3
= wx
.TextCtrl(panel3
, -1, word
)
76 fgs3
.Add(tc3
, flag
=wx
.LEFT
, border
=5)
78 panel2
.SetSizer( fgs2
)
79 panel2
.SetAutoLayout(1)
80 panel2
.SetupScrolling(scroll_y
= False)
82 panel3
.SetSizer( fgs3
)
83 panel3
.SetAutoLayout(1)
84 panel3
.SetupScrolling()
86 hbox
= wx
.BoxSizer(wx
.HORIZONTAL
)
91 vbox2
= wx
.BoxSizer(wx
.VERTICAL
)
99 vbox
.AddSizer(hbox
, 0)
101 self
.SetAutoLayout(1)
102 self
.SetupScrolling()
105 #----------------------------------------------------------------------
108 def runTest(frame
, nb
, log
):
109 win
= TestPanel(nb
, log
)
112 #----------------------------------------------------------------------
116 overview
= """<html><body>
117 wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
118 providing automatic scrollbar and scrolling behavior and the tab traversal
119 mangement that wxScrolledWindow lacks.
124 if __name__
== '__main__':
127 run
.main(['', os
.path
.basename(sys
.argv
[0])])