]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ScrolledPanel.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.
13 # 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
15 # o wxScrolledPanel -> ScrolledPanel
19 import wx
.lib
.scrolledpanel
as scrolled
21 #----------------------------------------------------------------------
23 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"
26 class TestPanel(scrolled
.ScrolledPanel
):
27 def __init__(self
, parent
, log
):
29 scrolled
.ScrolledPanel
.__init
__(self
, parent
, -1)
31 vbox
= wx
.BoxSizer(wx
.VERTICAL
)
32 desc
= wx
.StaticText(self
, -1,
33 "ScrolledPanel extends wx.ScrolledWindow, adding all "
34 "the necessary bits to set up scroll handling for you.\n\n"
35 "Here are three fixed size examples of its use. The "
36 "demo panel for this sample is also using it -- the \nwxStaticLine"
37 "below is intentionally made too long so a scrollbar will be "
40 desc
.SetForegroundColour("Blue")
41 vbox
.Add(desc
, 0, wx
.ALIGN_LEFT|wx
.ALL
, 5)
42 vbox
.Add(wx
.StaticLine(self
, -1, size
=(1024,-1)), 0, wx
.ALL
, 5)
47 panel1
= scrolled
.ScrolledPanel(self
, -1, size
=(120,300),
48 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
49 fgs1
= wx
.FlexGridSizer(cols
=2, vgap
=4, hgap
=4)
52 label
= wx
.StaticText(panel1
, -1, word
+":")
53 tc
= wx
.TextCtrl(panel1
, -1, word
, size
=(50,-1))
54 fgs1
.Add(label
, flag
=wx
.ALIGN_RIGHT | wx
.ALIGN_CENTER_VERTICAL
)
55 fgs1
.Add(tc
, flag
=wx
.EXPAND|wx
.RIGHT
, border
=25)
57 panel1
.SetSizer( fgs1
)
58 panel1
.SetAutoLayout(1)
59 panel1
.SetupScrolling( scroll_x
=False )
61 panel2
= scrolled
.ScrolledPanel(self
, -1, size
=(350, 40),
62 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
63 panel3
= scrolled
.ScrolledPanel(self
, -1, size
=(200,100),
64 style
= wx
.TAB_TRAVERSAL|wx
.SUNKEN_BORDER
)
66 fgs2
= wx
.FlexGridSizer(cols
=25, vgap
=4, hgap
=4)
67 fgs3
= wx
.FlexGridSizer(cols
=5, vgap
=4, hgap
=4)
69 for i
in range(len(words
)):
72 label2
= wx
.StaticText(panel2
, -1, word
)
73 fgs2
.Add(label2
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
74 label3
= wx
.StaticText(panel3
, -1, word
)
75 fgs3
.Add(label3
, flag
=wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
77 tc2
= wx
.TextCtrl(panel2
, -1, word
, size
=(50,-1))
78 fgs2
.Add(tc2
, flag
=wx
.LEFT
, border
=5)
79 tc3
= wx
.TextCtrl(panel3
, -1, word
)
80 fgs3
.Add(tc3
, flag
=wx
.LEFT
, border
=5)
82 panel2
.SetSizer( fgs2
)
83 panel2
.SetAutoLayout(1)
84 panel2
.SetupScrolling(scroll_y
= False)
86 panel3
.SetSizer( fgs3
)
87 panel3
.SetAutoLayout(1)
88 panel3
.SetupScrolling()
90 hbox
= wx
.BoxSizer(wx
.HORIZONTAL
)
95 vbox2
= wx
.BoxSizer(wx
.VERTICAL
)
103 vbox
.AddSizer(hbox
, 0)
105 self
.SetAutoLayout(1)
106 self
.SetupScrolling()
109 #----------------------------------------------------------------------
112 def runTest(frame
, nb
, log
):
113 win
= TestPanel(nb
, log
)
116 #----------------------------------------------------------------------
120 overview
= """<html><body>
121 ScrolledPanel fills a "hole" in the implementation of wx.ScrolledWindow,
122 providing automatic scrollbar and scrolling behavior and the tab traversal
123 mangement that wx.ScrolledWindow lacks.
128 if __name__
== '__main__':
131 run
.main(['', os
.path
.basename(sys
.argv
[0])])