[wxPython-users] Bug in _core.py or printout.py or C++?
Robin Dunn
robin at alldunn.com
Wed Jun 7 15:14:48 PDT 2006
Michael Hipp wrote:
> I'm trying to print a grid using wx.lib.printout.PrintGrid. Seems simple enough, I call it with:
>
> import wx.lib.printout as printout
> pgrid = printout.PrintGrid(self.frame, grid)
> pgrid.Preview()
>
> But I get this:
>
> IndexError: tuple index out of range
>
> [snip]
> File "c:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\lib\printout.py", line 1093, in OnBeginPrinting
> (w, h) = dc.GetSize()
> File "c:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line 909, in __getitem__
> def __getitem__(self, index): return self.Get()[index]
>
> The debugger tells me that 'index' walks thru 0, 1, 2 which is obviously wrong as Get() is supposed to return a (width,height) tuple with no 3rd element. Is this a bug buried in the C++ code or is there something I'm supposed to be doing differently.
Are you using WingIDE? If so then you probably just need to tell it to
ignore that exception because the IndexError is expected there. That is
what tells the tuple unpacker that it has reached the end of the
sequence. If you try it outside of the debugger it should work fine:
>>> import wx
>>> s = wx.Size(12,34)
>>> w,h = s
>>> w
12
>>> h
34
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list