2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
import wx
|
2004-01-13 03:17:17 +00:00
|
|
|
import wx.lib.scrolledpanel as scrolled
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
2003-12-22 19:09:54 +00:00
|
|
|
class TestPanel(scrolled.ScrolledPanel):
|
2003-03-25 06:35:27 +00:00
|
|
|
def __init__(self, parent, log):
|
|
|
|
self.log = log
|
2003-12-22 19:09:54 +00:00
|
|
|
scrolled.ScrolledPanel.__init__(self, parent, -1)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
vbox = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
desc = wx.StaticText(self, -1,
|
2004-01-03 01:14:17 +00:00
|
|
|
"ScrolledPanel extends wx.ScrolledWindow, adding all "
|
2003-03-25 06:35:27 +00:00
|
|
|
"the necessary bits to set up scroll handling for you.\n\n"
|
2003-07-02 23:13:10 +00:00
|
|
|
"Here are three fixed size examples of its use. The "
|
2004-01-13 03:17:17 +00:00
|
|
|
"demo panel for this sample is also using it -- the \nwxStaticLine "
|
2003-07-02 23:13:10 +00:00
|
|
|
"below is intentionally made too long so a scrollbar will be "
|
|
|
|
"activated."
|
2003-03-25 06:35:27 +00:00
|
|
|
)
|
|
|
|
desc.SetForegroundColour("Blue")
|
2003-12-09 01:23:28 +00:00
|
|
|
vbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
|
|
|
vbox.Add(wx.StaticLine(self, -1, size=(1024,-1)), 0, wx.ALL, 5)
|
2003-11-22 22:57:49 +00:00
|
|
|
vbox.Add((20,20))
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
words = text.split()
|
|
|
|
|
2004-05-28 04:22:16 +00:00
|
|
|
panel1 = scrolled.ScrolledPanel(self, -1, size=(140, 300),
|
|
|
|
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel1" )
|
2003-12-09 01:23:28 +00:00
|
|
|
fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
for word in words:
|
2003-12-09 01:23:28 +00:00
|
|
|
label = wx.StaticText(panel1, -1, word+":")
|
2004-05-28 05:03:12 +00:00
|
|
|
|
|
|
|
# A test for scrolling with a too big control
|
|
|
|
#if word == "three":
|
|
|
|
# tc = wx.TextCtrl(panel1, -1, word, size=(150,-1))
|
|
|
|
#else:
|
|
|
|
# tc = wx.TextCtrl(panel1, -1, word, size=(50,-1))
|
|
|
|
|
|
|
|
tc = wx.TextCtrl(panel1, -1, word, size=(50,-1))
|
|
|
|
|
2004-05-28 04:22:16 +00:00
|
|
|
fgs1.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10)
|
|
|
|
fgs1.Add(tc, flag=wx.RIGHT, border=10)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
panel1.SetSizer( fgs1 )
|
|
|
|
panel1.SetAutoLayout(1)
|
2004-05-28 04:22:16 +00:00
|
|
|
panel1.SetupScrolling()
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2004-05-28 04:22:16 +00:00
|
|
|
panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 50),
|
|
|
|
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel2")
|
2003-12-22 19:09:54 +00:00
|
|
|
panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100),
|
2004-05-28 04:22:16 +00:00
|
|
|
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel3")
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4)
|
|
|
|
fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
for i in range(len(words)):
|
|
|
|
word = words[i]
|
|
|
|
if i % 5 != 4:
|
2003-12-09 01:23:28 +00:00
|
|
|
label2 = wx.StaticText(panel2, -1, word)
|
|
|
|
fgs2.Add(label2, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
|
|
|
|
label3 = wx.StaticText(panel3, -1, word)
|
|
|
|
fgs3.Add(label3, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
|
2003-03-25 06:35:27 +00:00
|
|
|
else:
|
2003-12-09 01:23:28 +00:00
|
|
|
tc2 = wx.TextCtrl(panel2, -1, word, size=(50,-1))
|
|
|
|
fgs2.Add(tc2, flag=wx.LEFT, border=5)
|
|
|
|
tc3 = wx.TextCtrl(panel3, -1, word )
|
|
|
|
fgs3.Add(tc3, flag=wx.LEFT, border=5)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
panel2.SetSizer( fgs2 )
|
|
|
|
panel2.SetAutoLayout(1)
|
|
|
|
panel2.SetupScrolling(scroll_y = False)
|
|
|
|
|
|
|
|
panel3.SetSizer( fgs3 )
|
|
|
|
panel3.SetAutoLayout(1)
|
|
|
|
panel3.SetupScrolling()
|
|
|
|
|
2003-12-11 19:55:48 +00:00
|
|
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
2003-11-22 22:57:49 +00:00
|
|
|
hbox.Add((20,20))
|
2004-05-28 05:03:12 +00:00
|
|
|
hbox.Add(panel1, 0, wx.FIXED_MINSIZE)
|
2003-11-22 22:57:49 +00:00
|
|
|
hbox.Add((40, 10))
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
vbox2 = wx.BoxSizer(wx.VERTICAL)
|
2004-05-28 05:03:12 +00:00
|
|
|
vbox2.Add(panel2, 0, wx.FIXED_MINSIZE)
|
2003-11-22 22:57:49 +00:00
|
|
|
vbox2.Add((20, 50))
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2004-05-28 05:03:12 +00:00
|
|
|
vbox2.Add(panel3, 0, wx.FIXED_MINSIZE)
|
2003-11-22 22:57:49 +00:00
|
|
|
vbox2.Add((20, 10))
|
2003-03-25 06:35:27 +00:00
|
|
|
hbox.Add(vbox2)
|
|
|
|
|
2004-05-02 02:41:33 +00:00
|
|
|
vbox.Add(hbox, 0)
|
2003-03-25 06:35:27 +00:00
|
|
|
self.SetSizer(vbox)
|
|
|
|
self.SetAutoLayout(1)
|
|
|
|
self.SetupScrolling()
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overview = """<html><body>
|
2004-01-03 01:14:17 +00:00
|
|
|
ScrolledPanel fills a "hole" in the implementation of wx.ScrolledWindow,
|
2003-03-25 06:35:27 +00:00
|
|
|
providing automatic scrollbar and scrolling behavior and the tab traversal
|
2004-01-03 01:14:17 +00:00
|
|
|
mangement that wx.ScrolledWindow lacks.
|
2003-03-25 06:35:27 +00:00
|
|
|
</body></html>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|