]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/wxScrolledPanel.py
added visual c++ makefiles
[wxWidgets.git] / wxPython / demo / wxScrolledPanel.py
... / ...
CommitLineData
1from wxPython.wx import *
2from wxPython.lib.scrolledpanel import wxScrolledPanel
3
4#----------------------------------------------------------------------
5
6text = "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"
7
8
9class TestPanel(wxScrolledPanel):
10 def __init__(self, parent, log):
11 self.log = log
12 wxScrolledPanel.__init__(self, parent, -1)
13
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."
20 )
21 desc.SetForegroundColour("Blue")
22 vbox.Add(desc, 0, wxALIGN_LEFT|wxALL, 5)
23 vbox.Add(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
24 vbox.AddSpacer(20,20)
25
26 words = text.split()
27
28 panel1 = wxScrolledPanel(self, -1, size=(120,300),
29 style = wxTAB_TRAVERSAL|wxSUNKEN_BORDER )
30 fgs1 = wxFlexGridSizer(cols=2, vgap=4, hgap=4)
31
32 for word in words:
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)
37
38 panel1.SetSizer( fgs1 )
39 panel1.SetAutoLayout(1)
40 panel1.SetupScrolling( scroll_x=False )
41
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)
46
47 fgs2 = wxFlexGridSizer(cols=25, vgap=4, hgap=4)
48 fgs3 = wxFlexGridSizer(cols=5, vgap=4, hgap=4)
49
50 for i in range(len(words)):
51 word = words[i]
52 if i % 5 != 4:
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)
57 else:
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)
62
63 panel2.SetSizer( fgs2 )
64 panel2.SetAutoLayout(1)
65 panel2.SetupScrolling(scroll_y = False)
66
67 panel3.SetSizer( fgs3 )
68 panel3.SetAutoLayout(1)
69 panel3.SetupScrolling()
70
71 hbox = wxBoxSizer(wxHORIZONTAL)
72 hbox.AddSpacer(20,20)
73 hbox.Add(panel1, 0)
74 hbox.AddSpacer(40, 10)
75
76 vbox2 = wxBoxSizer(wxVERTICAL)
77 vbox2.Add(panel2, 0)
78 vbox2.AddSpacer(20, 50)
79
80 vbox2.Add(panel3, 0)
81 vbox2.AddSpacer(20, 10)
82 hbox.Add(vbox2)
83
84 vbox.AddSizer(hbox, 0)
85 self.SetSizer(vbox)
86 self.SetAutoLayout(1)
87 self.SetupScrolling()
88
89
90#----------------------------------------------------------------------
91
92
93def runTest(frame, nb, log):
94 win = TestPanel(nb, log)
95 return win
96
97#----------------------------------------------------------------------
98
99
100
101overview = """<html><body>
102wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
103providing automatic scrollbar and scrolling behavior and the tab traversal
104mangement that wxScrolledWindow lacks.
105</body></html>
106"""
107
108
109if __name__ == '__main__':
110 import sys,os
111 import run
112 run.main(['', os.path.basename(sys.argv[0])])