Hello All,
I’m probably making a really stupid mistake
here! I’ve tried playing around with ScrolledPanel and can’t
get the scrolling to work (which is a bit of a disadvantage with such a
control).
The following program always blows up at the statement “self.panel.SetupScrolling()”.
The error I receive is:
IndexError: tuple index out of range
Traceback (innermost last):
File “d:\MyProjects\multi_frames\test_app.py”,
line 1, in ?
import wx
File “d:\MyProjects\multi_frames\test_app.py”,
line 46, in ?
app = TestApp()
File “C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx_core.py”,
line 7668, in init
self._BootstrapApp()
File
“C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx_core.py”, line
7320, in _BootstrapApp
return core.PyApp__BootstrapApp(*args, **kwargs)
File “d:\MyProjects\multi_frames\test_app.py”,
line 33, in OnInit
self.gui = MainFrame(None)
File “d:\MyProjects\multi_frames\test_app.py”,
line 27, in init
self.panel.SetupScrolling()
File “C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\lib\scrolledpanel.py”,
line 62, in SetupScrolling
w, h = sizer.GetMinSize()
File
“C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx_core.py”, line
909, in getitem
def getitem(self, index):
return self.Get()[index]
If I remove the statement the window displays without
scroll-bars. Any help would be gratefully appreciated (including
admonishments for making dumb mistakes).
For the record I’m running this using Python 2.4.2 and
wxPython 2.6.2.1 (Unicode).
Cheers!!
Here is the sample code:
import wx
import wx.lib.scrolledpanel as scrolled
class MainFrame(wx.Frame):
def
init(self, parent):
wx.Frame.__init__(self,
parent,-1, “Test Scrolled Panel”)
self.panel
= scrolled.ScrolledPanel(self, -1)
self.panel.SetBackgroundColour(wx.WHITE)
self.item_boxes
= []
self.items
= []
self.main_box
= wx.BoxSizer(wx.VERTICAL)
for
i in range(0, 33):
lbl
= wx.StaticText(self.panel, -1, “Field:”, style=wx.ALIGN_RIGHT)
txt
= wx.TextCtrl(self.panel, -1, “”, style=wx.TE_MULTILINE)
item_box
= wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
item_box.AddGrowableCol(1)
item_box.Add(lbl,
0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_RIGHT)
item_box.SetItemMinSize(0,
50, -1)
item_box.Add(txt,
0, wx.EXPAND)
self.main_box.Add(item_box,
0, border=2, flag=wx.EXPAND|wx.BOTTOM)
self.panel.SetSizer(self.main_box)
self.panel.SetAutoLayout(1)
self.panel.SetupScrolling()
class TestApp(wx.App):
def
OnInit(self):
self.gui
= MainFrame(None)
self.SetTopWindow(self.gui)
self.gui.Show()
return
True
if name == ‘main’:
app
= TestApp()
app.MainLoop()
Dermot
Doran Sr Technical Support Engineer
EMC GTS Solutions Level 2 Infrastructure Services
Office: +353-21-4281500 (x5474)
Mobile:
+31-6-55815258
Worldwide Customer Support Number: + 800 782 43622