Help needed to get ScrolledPanel scrolling!

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

Hello All,

It may seem to be a bit odd to reply to
oneself, but I’ve discovered that the IDE I’m using was trapping
the exception! I’m using Wing IDE and it traps this IndexError
exception!

The question I have now is, should this
exception be generated? I’ve adapted the program from the Demo and it
generates the same exception.

Interested to know!

Cheers!!

Dermot.

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

···

From: Doran_Dermot@emc.com
[mailto:Doran_Dermot@emc.com]
Sent: 29 June 2006 16:38
To:
wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] Help
needed to get ScrolledPanel scrolling!

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

It may seem to be a bit odd to reply to oneself,

No. The point about this type of list is that, if you solve a particular problem, you share the solution with the community:
1. This means that others who might have a similar problem can search archives for your solution, and
2. It means that those on the list who were trying to reproduce your problem in an effort to assist you (and perhaps investigate a possible bug) know that this is no longer necessary.
:slight_smile:

Doran_Dermot@emc.com wrote:

···

Hello All,

It may seem to be a bit odd to reply to oneself, but I’ve discovered that the IDE I’m using was trapping the exception! I’m using Wing IDE and it traps this IndexError exception!

The question I have now is, should this exception be generated? I’ve adapted the program from the Demo and it generates the same exception.

Interested to know!

Cheers!!

Dermot.

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

------------------------------------------------------------------------

*From:* Doran_Dermot@emc.com [mailto:Doran_Dermot@emc.com]
*Sent:* 29 June 2006 16:38
*To:* wxPython-users@lists.wxwidgets.org
*Subject:* [wxPython-users] Help needed to get ScrolledPanel scrolling!

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

--
Dave Coventry
Tel: +27(0)31 7644107
Fax: +27(0)31 7644107
Cell: +27(0)82 3685983

Doran_Dermot@emc.com wrote:

Hello All,

It may seem to be a bit odd to reply to oneself, but I’ve discovered that the IDE I’m using was trapping the exception! I’m using Wing IDE and it traps this IndexError exception!

The question I have now is, should this exception be generated?

Yes. When you have a statement like this:

  a, b = some_sequence_like_object

Then Python iterates over the sequence using __getitem__ to extract the values from it. IndexError is how Python knows it has reached the end of the sequence, but since it is not a standard type that WingIDE knows about it catches it in the debugger and shows it to you. You can tell Wing to ignore that exception when it is raised from that function and then it will work as you expect.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Thanks very much for the explanation!

Cheers!!

Dermot.

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

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: 29 June 2006 18:15
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Help needed to get ScrolledPanel
scrolling!

Doran_Dermot@emc.com wrote:

Hello All,

It may seem to be a bit odd to reply to oneself, but I've discovered
that the IDE I'm using was trapping the exception! I'm using Wing IDE

and it traps this IndexError exception!

The question I have now is, should this exception be generated?

Yes. When you have a statement like this:

  a, b = some_sequence_like_object

Then Python iterates over the sequence using __getitem__ to extract the
values from it. IndexError is how Python knows it has reached the end
of the sequence, but since it is not a standard type that WingIDE knows
about it catches it in the debugger and shows it to you. You can tell
Wing to ignore that exception when it is raised from that function and
then it will work as you expect.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Dave,

Good point! I just felt a bit silly sending out the email without
having researched it enough! Still it has led to Robin Dunn supplying
me with a very good explanation of why the exception is raised.

Winners all round then!

Cheers!!

Dermot.

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

···

-----Original Message-----
From: Dave Coventry [mailto:dc@docndraft.com]
Sent: 29 June 2006 17:07
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Help needed to get ScrolledPanel
scrolling!

>It may seem to be a bit odd to reply to oneself,
No. The point about this type of list is that, if you solve a particular

problem, you share the solution with the community:
1. This means that others who might have a similar problem can search
archives for your solution, and
2. It means that those on the list who were trying to reproduce your
problem in an effort to assist you (and perhaps investigate a possible
bug) know that this is no longer necessary.
:slight_smile:

Doran_Dermot@emc.com wrote:

Hello All,

It may seem to be a bit odd to reply to oneself, but I've discovered
that the IDE I'm using was trapping the exception! I'm using Wing IDE
and it traps this IndexError exception!

The question I have now is, should this exception be generated? I've
adapted the program from the Demo and it generates the same exception.

Interested to know!

Cheers!!

Dermot.

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

------------------------------------------------------------------------

*From:* Doran_Dermot@emc.com [mailto:Doran_Dermot@emc.com]
*Sent:* 29 June 2006 16:38
*To:* wxPython-users@lists.wxwidgets.org
*Subject:* [wxPython-users] Help needed to get ScrolledPanel

scrolling!

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.p
y",

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

--
Dave Coventry
Tel: +27(0)31 7644107
Fax: +27(0)31 7644107
Cell: +27(0)82 3685983

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org