1 from wxPython
.wx
import *
2 from wxPython
.lib
.scrolledpanel
import wxScrolledPanel
4 #----------------------------------------------------------------------
6 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"
9 class TestPanel(wxScrolledPanel
):
10 def __init__(self
, parent
, log
):
12 wxScrolledPanel
.__init
__(self
, parent
, -1)
14 vbox
= wxBoxSizer(wxVERTICAL
)
15 desc
= wxStaticText(self
, -1,
16 "wxScrolledPanel extends wxScrolledWindow, adding all "
17 "the necessary bits to set up scroll handling for you.\n\n"
18 "Here are three fixed size examples of its use. The "
19 "demo panel for this sample is also using it -- the \nwxStaticLine"
20 "below is intentionally made too long so a scrollbar will be "
23 desc
.SetForegroundColour("Blue")
24 vbox
.Add(desc
, 0, wxALIGN_LEFT|wxALL
, 5)
25 vbox
.Add(wxStaticLine(self
, -1, size
=(1024,-1)), 0, wxALL
, 5)
30 panel1
= wxScrolledPanel(self
, -1, size
=(120,300),
31 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
32 fgs1
= wxFlexGridSizer(cols
=2, vgap
=4, hgap
=4)
35 label
= wxStaticText(panel1
, -1, word
+":")
36 tc
= wxTextCtrl(panel1
, -1, word
, size
=(50,-1))
37 fgs1
.Add(label
, flag
=wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL
)
38 fgs1
.Add(tc
, flag
=wxEXPAND|wxRIGHT
, border
=25)
40 panel1
.SetSizer( fgs1
)
41 panel1
.SetAutoLayout(1)
42 panel1
.SetupScrolling( scroll_x
=False )
44 panel2
= wxScrolledPanel(self
, -1, size
=(350, 40),
45 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
46 panel3
= wxScrolledPanel(self
, -1, size
=(200,100),
47 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
49 fgs2
= wxFlexGridSizer(cols
=25, vgap
=4, hgap
=4)
50 fgs3
= wxFlexGridSizer(cols
=5, vgap
=4, hgap
=4)
52 for i
in range(len(words
)):
55 label2
= wxStaticText(panel2
, -1, word
)
56 fgs2
.Add(label2
, flag
=wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
)
57 label3
= wxStaticText(panel3
, -1, word
)
58 fgs3
.Add(label3
, flag
=wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
)
60 tc2
= wxTextCtrl(panel2
, -1, word
, size
=(50,-1))
61 fgs2
.Add(tc2
, flag
=wxLEFT
, border
=5)
62 tc3
= wxTextCtrl(panel3
, -1, word
)
63 fgs3
.Add(tc3
, flag
=wxLEFT
, border
=5)
65 panel2
.SetSizer( fgs2
)
66 panel2
.SetAutoLayout(1)
67 panel2
.SetupScrolling(scroll_y
= False)
69 panel3
.SetSizer( fgs3
)
70 panel3
.SetAutoLayout(1)
71 panel3
.SetupScrolling()
73 hbox
= wxBoxSizer(wxHORIZONTAL
)
76 hbox
.AddSpacer(40, 10)
78 vbox2
= wxBoxSizer(wxVERTICAL
)
80 vbox2
.AddSpacer(20, 50)
83 vbox2
.AddSpacer(20, 10)
86 vbox
.AddSizer(hbox
, 0)
92 #----------------------------------------------------------------------
95 def runTest(frame
, nb
, log
):
96 win
= TestPanel(nb
, log
)
99 #----------------------------------------------------------------------
103 overview
= """<html><body>
104 wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
105 providing automatic scrollbar and scrolling behavior and the tab traversal
106 management that wxScrolledWindow lacks.
111 if __name__
== '__main__':
114 run
.main(['', os
.path
.basename(sys
.argv
[0])])