ULC Virtual List Mode doesn't work on OSX!!!

The following code works perfectly fine on Windows XP/7. But, it fails
on OSX.

import wx
import random
import os, sys
from wx.lib.agw import ultimatelistctrl as ULC

class TestUltimateListCtrl(ULC.UltimateListCtrl):
    def __init__(self, parent, log):
        ULC.UltimateListCtrl.__init__(self, parent, -1,
agwStyle=ULC.ULC_VIRTUAL|ULC.ULC_REPORT|ULC.ULC_SINGLE_SEL|
ULC.ULC_VRULES|ULC.ULC_HRULES)
        self.SetItemCount(1000)
        self.table_fields=['First','Second','Third']
        field_index=0
        for field in self.table_fields:
            info = ULC.UltimateListItem()
            info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE |
wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK
            info._image = []
            info._format = wx.LIST_FORMAT_CENTER
            info._kind = 1
            info._text = field
            info._font= wx.Font(13, wx.ROMAN, wx.NORMAL, wx.BOLD)
            self.InsertColumnInfo(field_index, info)
            self.SetColumnWidth(field_index,175)
            field_index += 1

        self.checked = []
        self.Bind(ULC.EVT_LIST_ITEM_CHECKING, self.OnCheck)

    def OnCheck(self, event):
        item_column = (event.m_itemIndex, event.m_item.GetColumn())
        try:
            idx = self.checked.index(item_column)
            print idx
        except ValueError:
            idx = None

        if idx == None:
            self.checked.append(item_column)
        else:
            del(self.checked[idx])
        self.Refresh()

    def getColumnText(self, index, col):
        item = self.GetItem(index, col)
        return item.GetText()

    def OnGetItemText(self, item, col):
        return "Item %d, Column %d" % (item,col)

    def OnGetItemColumnImage(self, item, col):
        return []

    def OnGetItemImage(self, item):
        return []

    def OnGetItemAttr(self, item):
        return None

    def OnGetItemTextColour(self, item, col):
        return None

    def OnGetItemToolTip(self, item, col):
        return None

    def OnGetItemKind(self, item):
        return 1

    def OnGetItemColumnKind(self, item, col):
        if col==0:
            return self.OnGetItemKind(item)
        return 0

    def OnGetItemColumnCheck(self, item, column):
        item_column = (item, column)
        if item_column in self.checked:
            return True
        else:
            return False

class TestFrame(wx.Frame):
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, -1, "UltimateListCtrl in
wx.LC_VIRTUAL mode", size=(700, 600))
        panel = wx.Panel(self, -1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        listCtrl = TestUltimateListCtrl(panel, log)
        sizer.Add(listCtrl, 1, wx.EXPAND)
        panel.SetSizer(sizer)
        sizer.Layout()
        self.CenterOnScreen()
        self.Show()

if __name__ == '__main__':
    import sys
    app = wx.PySimpleApp()
    frame = TestFrame(None, sys.stdout)
    frame.Show(True)
    app.MainLoop()

The error occurs if the mouse across the window containing the list.

Following is the error stack:

Exception: invalid item index in GetItem
File "/Users/admin/NJHMIS/NJHMIS_Dashboard_wxPython/
ULC_Virtual_Column_Checking.py", line 95, in <module>
  app.MainLoop()
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/_core.py", line 8622, in MainLoop
  wx.PyApp.MainLoop(self)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/_core.py", line 7914, in MainLoop
  return _core_.PyApp_MainLoop(*args, **kwargs)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 7485, in
OnMouse
  newItem, hitResult = self.HitTestLine(current, x, y)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 6800, in
HitTestLine
  newItem = self.GetParent().GetItem(line, col)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 11213, in
GetItem
  return self._mainWin.GetItem(item, col)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 8946, in
GetItem
  raise Exception("invalid item index in GetItem")

Again, like I said, this works absolutely fine on Windows XP/7.
Haven't tested it on Linux yet.

Hi,

<snip>

The error occurs if the mouse across the window containing the list.

Following is the error stack:

Exception: invalid item index in GetItem
File "/Users/admin/NJHMIS/NJHMIS_Dashboard_wxPython/
ULC_Virtual_Column_Checking.py", line 95, in <module>
app.MainLoop()
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/_core.py", line 8622, in MainLoop
wx.PyApp.MainLoop(self)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/_core.py", line 7914, in MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 7485, in
OnMouse
newItem, hitResult = self.HitTestLine(current, x, y)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 6800, in
HitTestLine
newItem = self.GetParent().GetItem(line, col)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 11213, in
GetItem
return self._mainWin.GetItem(item, col)
File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 8946, in
GetItem
raise Exception("invalid item index in GetItem")

Again, like I said, this works absolutely fine on Windows XP/7.
Haven't tested it on Linux yet.

I am not sure what the problem is, as I don't have a Mac to test it
on. It would be nice if you could go on line 8946 in ULC and add a
print statement like this:

print item._itemId, col

*before* the line that raises the exception. Maybe this might give me
a clue on what's going on.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 23 February 2012 18:13, Ven wrote:

Thanks for the reply. Added the statement on line 8944, just before
the if statement which raises the exception. Result is: -11,1. Not
sure why the negative index is coming. Like I said, the code breaks
only after a mouse movement. Specifically during a bottom-to-top or
right-to-left mouse gesture. My guess is it's calculating the screen
co-ordinates wrong during the mouse movement or probably starting out
wrong when calculating the screen size (resolution) while building the
list control itself. But, I am not sure. Any help would be greatly
appreciated.

···

On Feb 24, 1:58 am, Andrea Gavana <andrea.gav...@gmail.com> wrote:

Hi,

On 23 February 2012 18:13, Ven wrote:
<snip>

> The error occurs if the mouse across the window containing the list.

> Following is the error stack:

> Exception: invalid item index in GetItem
> File "/Users/admin/NJHMIS/NJHMIS_Dashboard_wxPython/
> ULC_Virtual_Column_Checking.py", line 95, in <module>
> app.MainLoop()
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/_core.py", line 8622, in MainLoop
> wx.PyApp.MainLoop(self)
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/_core.py", line 7914, in MainLoop
> return _core_.PyApp_MainLoop(*args, **kwargs)
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 7485, in
> OnMouse
> newItem, hitResult = self.HitTestLine(current, x, y)
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 6800, in
> HitTestLine
> newItem = self.GetParent().GetItem(line, col)
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 11213, in
> GetItem
> return self._mainWin.GetItem(item, col)
> File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 8946, in
> GetItem
> raise Exception("invalid item index in GetItem")

> Again, like I said, this works absolutely fine on Windows XP/7.
> Haven't tested it on Linux yet.

I am not sure what the problem is, as I don't have a Mac to test it
on. It would be nice if you could go on line 8946 in ULC and add a
print statement like this:

print item._itemId, col

*before* the line that raises the exception. Maybe this might give me
a clue on what's going on.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."http://xoomer.alice.it/infinity77/

Btw, I am using Activestate Python 2.7.2 with wxpython 2.9.2.4 on OSX
10.7.3.

···

On Feb 24, 8:56 am, Ven <praveen.venk...@gmail.com> wrote:

Thanks for the reply. Added the statement on line 8944, just before
the if statement which raises the exception. Result is: -11,1. Not
sure why the negative index is coming. Like I said, the code breaks
only after a mouse movement. Specifically during a bottom-to-top or
right-to-left mouse gesture. My guess is it's calculating the screen
co-ordinates wrong during the mouse movement or probably starting out
wrong when calculating the screen size (resolution) while building the
list control itself. But, I am not sure. Any help would be greatly
appreciated.

On Feb 24, 1:58 am, Andrea Gavana <andrea.gav...@gmail.com> wrote:

> Hi,

> On 23 February 2012 18:13, Ven wrote:
> <snip>

> > The error occurs if the mouse across the window containing the list.

> > Following is the error stack:

> > Exception: invalid item index in GetItem
> > File "/Users/admin/NJHMIS/NJHMIS_Dashboard_wxPython/
> > ULC_Virtual_Column_Checking.py", line 95, in <module>
> > app.MainLoop()
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/_core.py", line 8622, in MainLoop
> > wx.PyApp.MainLoop(self)
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/_core.py", line 7914, in MainLoop
> > return _core_.PyApp_MainLoop(*args, **kwargs)
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 7485, in
> > OnMouse
> > newItem, hitResult = self.HitTestLine(current, x, y)
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 6800, in
> > HitTestLine
> > newItem = self.GetParent().GetItem(line, col)
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 11213, in
> > GetItem
> > return self._mainWin.GetItem(item, col)
> > File "/usr/local/lib/wxPython-2.9.2.4/lib/python2.7/site-packages/
> > wx-2.9.2-osx_cocoa/wx/lib/agw/ultimatelistctrl.py", line 8946, in
> > GetItem
> > raise Exception("invalid item index in GetItem")

> > Again, like I said, this works absolutely fine on Windows XP/7.
> > Haven't tested it on Linux yet.

> I am not sure what the problem is, as I don't have a Mac to test it
> on. It would be nice if you could go on line 8946 in ULC and add a
> print statement like this:

> print item._itemId, col

> *before* the line that raises the exception. Maybe this might give me
> a clue on what's going on.

> Andrea.

> "Imagination Is The Only Weapon In The War Against Reality."http://xoomer.alice.it/infinity77/

Here are some clues: It's happening for me only when the ULC is scrolled all the way to the top and the mouse moves upwards out of the ULC and the cursor is over the column header or the frame's caption bar. So it appears that it is getting mouse motion events for the header that it isn't expecting and that results in an exception because there is no item at that position, and then because of that the mouse is not released or something and the bad events continue to flow as long as the cursor is above the first item in the list.

···

On 2/23/12 10:58 PM, Andrea Gavana wrote:

I am not sure what the problem is, as I don't have a Mac to test it
on. It would be nice if you could go on line 8946 in ULC and add a
print statement like this:

print item._itemId, col

*before* the line that raises the exception. Maybe this might give me
a clue on what's going on.

--
Robin Dunn
Software Craftsman

Any progress on this one?

···

On Feb 24, 1:58 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 2/23/12 10:58 PM, Andrea Gavana wrote:

> I am not sure what the problem is, as I don't have a Mac to test it
> on. It would be nice if you could go on line 8946 in ULC and add a
> print statement like this:

> print item._itemId, col

> *before* the line that raises the exception. Maybe this might give me
> a clue on what's going on.

Here are some clues: It's happening for me only when the ULC is
scrolled all the way to the top and the mouse moves upwards out of the
ULC and the cursor is over the column header or the frame's caption bar.
So it appears that it is getting mouse motion events for the header
that it isn't expecting and that results in an exception because there
is no item at that position, and then because of that the mouse is not
released or something and the bad events continue to flow as long as the
cursor is above the first item in the list.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Hi Ven,

Any progress on this one?

> I am not sure what the problem is, as I don't have a Mac to test it
> on. It would be nice if you could go on line 8946 in ULC and add a
> print statement like this:

> print item._itemId, col

> *before* the line that raises the exception. Maybe this might give me
> a clue on what's going on.

Here are some clues: It's happening for me only when the ULC is
scrolled all the way to the top and the mouse moves upwards out of the
ULC and the cursor is over the column header or the frame's caption bar.
So it appears that it is getting mouse motion events for the header
that it isn't expecting and that results in an exception because there
is no item at that position, and then because of that the mouse is not
released or something and the bad events continue to flow as long as the
cursor is above the first item in the list.

I am sorry I can't do pretty much anything as I can not test any
change I may think of. The fact that, as far as I know, ULC works
relatively well on Windows and Linux makes me think that there is
something bogus on the Calc(Un)ScrolledPosition on the Mac, but I have
no idea if this is the case and what I can do to fix the issue.

Until someone with a Mac steps up and tries to debug the issue, there
is not much more I can do.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 29 February 2012 17:32, Ven wrote:

On Feb 24, 1:58 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 2/23/12 10:58 PM, Andrea Gavana wrote: