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, and the "
19 "mail demo panel is also using it."
21 desc
.SetForegroundColour("Blue")
22 vbox
.Add(desc
, 0, wxALIGN_LEFT|wxALL
, 5)
23 vbox
.Add(wxStaticLine(self
, -1), 0, wxEXPAND|wxALL
, 5)
28 panel1
= wxScrolledPanel(self
, -1, size
=(120,300),
29 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
30 fgs1
= wxFlexGridSizer(cols
=2, vgap
=4, hgap
=4)
33 label
= wxStaticText(panel1
, -1, word
+":")
34 tc
= wxTextCtrl(panel1
, -1, word
, size
=(50,-1))
35 fgs1
.Add(label
, flag
=wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL
)
36 fgs1
.Add(tc
, flag
=wxEXPAND|wxRIGHT
, border
=25)
38 panel1
.SetSizer( fgs1
)
39 panel1
.SetAutoLayout(1)
40 panel1
.SetupScrolling( scroll_x
=False )
42 panel2
= wxScrolledPanel(self
, -1, size
=(350, 40),
43 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
44 panel3
= wxScrolledPanel(self
, -1, size
=(200,100),
45 style
= wxTAB_TRAVERSAL|wxSUNKEN_BORDER
)
47 fgs2
= wxFlexGridSizer(cols
=25, vgap
=4, hgap
=4)
48 fgs3
= wxFlexGridSizer(cols
=5, vgap
=4, hgap
=4)
50 for i
in range(len(words
)):
53 label2
= wxStaticText(panel2
, -1, word
)
54 fgs2
.Add(label2
, flag
=wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
)
55 label3
= wxStaticText(panel3
, -1, word
)
56 fgs3
.Add(label3
, flag
=wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
)
58 tc2
= wxTextCtrl(panel2
, -1, word
, size
=(50,-1))
59 fgs2
.Add(tc2
, flag
=wxLEFT
, border
=5)
60 tc3
= wxTextCtrl(panel3
, -1, word
)
61 fgs3
.Add(tc3
, flag
=wxLEFT
, border
=5)
63 panel2
.SetSizer( fgs2
)
64 panel2
.SetAutoLayout(1)
65 panel2
.SetupScrolling(scroll_y
= False)
67 panel3
.SetSizer( fgs3
)
68 panel3
.SetAutoLayout(1)
69 panel3
.SetupScrolling()
71 hbox
= wxBoxSizer(wxHORIZONTAL
)
74 hbox
.AddSpacer(40, 10)
76 vbox2
= wxBoxSizer(wxVERTICAL
)
78 vbox2
.AddSpacer(20, 50)
81 vbox2
.AddSpacer(20, 10)
84 vbox
.AddSizer(hbox
, 0)
90 #----------------------------------------------------------------------
93 def runTest(frame
, nb
, log
):
94 win
= TestPanel(nb
, log
)
97 #----------------------------------------------------------------------
101 overview
= """<html><body>
102 wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
103 providing automatic scrollbar and scrolling behavior and the tab traversal
104 mangement that wxScrolledWindow lacks.
109 if __name__
== '__main__':
112 run
.main(['', os
.path
.basename(sys
.argv
[0])])