UltimateListCtrl problem - border around last item not erased after delete

Hello,

I use a virtual UltimateListCtrl. When I delete the last item with the
Delete-Key, I call SetItemCount with the new item-count. The item is
deleted, but the border around the item is still visible. Is there
something wrong in my code ?
wx: 2.8.12.1, MSW

Sample:
import wx
import wx.lib.agw.ultimatelistctrl as ulc

class ULCVirtual(ulc.UltimateListCtrl):
    def __init__(self, parent, style, agwstyle):
        agwstyle |= ulc.ULC_VIRTUAL
        ulc.UltimateListCtrl.__init__(self, parent, -1,
              style=style, agwStyle=agwstyle)
    def OnGetItemColumnKind(self, item, column=0):
        return 0
    def OnGetItemText(self, item, col):
        return "item {0}".format(item)
    def OnGetItemToolTip(self, item, col):
        return "item {0}".format(item)
    def OnGetItemTextColour(self, item, col):
        return wx.NullColour
    def OnGetItemColumnCheck(self, item, column=0):
        return False
    def OnGetItemAttr(self, item_idx):
        return ulc.UltimateListItemAttr()

class TestFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Test")
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        self.item_count = 5
        self.ulc = ULCVirtual(self,
            style=wx.NO_BORDER, agwstyle=ulc.ULC_REPORT)
        for i in range(2):
            self.ulc.InsertColumn(i, str(i))
        self.ulc.SetItemCount(self.item_count)
        sizer.Add(self.ulc, 1, wx.EXPAND)

        self.ulc.Bind(wx.EVT_LIST_KEY_DOWN, self.OnKeyDown)

    def OnKeyDown(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_DELETE:
            self.item_count -= 1
            self.ulc.SetItemCount(self.item_count)
        event.Skip()

app = wx.PySimpleApp()
TestFrame().Show()
app.MainLoop()

Regards,
Erwin

Hi,

Hello,

I use a virtual UltimateListCtrl. When I delete the last item with the
Delete-Key, I call SetItemCount with the new item-count. The item is
deleted, but the border around the item is still visible. Is there
something wrong in my code ?

Not that I can see, and it doesn't happen to me using AGW from SVN on
Windows Vista, wxPython 2.9.2.4. If you are using the standard AGW
distributed with wxPython, I would suggest to upgrade to 2.9 or to use
AGW from SVN.

Andrea.

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

···

On 6 February 2012 22:53, ErwinP wrote:

Hi,

···

On 7 Feb., 08:38, Andrea Gavana <andrea.gav...@gmail.com> wrote:

Not that I can see, and it doesn't happen to me using AGW from SVN on
Windows Vista, wxPython 2.9.2.4. If you are using the standard AGW
distributed with wxPython, I would suggest to upgrade to 2.9 or to use
AGW from SVN.

I tried wx:2.9.3.1,agw:0.9.2 and I also copied the wx\lib\agw folder
from
SVN to this installation - with no sucess, the border is still visible
after delete.

Regards,
Erwin

Hi,

Hi,

Not that I can see, and it doesn't happen to me using AGW from SVN on
Windows Vista, wxPython 2.9.2.4. If you are using the standard AGW
distributed with wxPython, I would suggest to upgrade to 2.9 or to use
AGW from SVN.

I tried wx:2.9.3.1,agw:0.9.2 and I also copied the wx\lib\agw folder
from
SVN to this installation - with no sucess, the border is still visible
after delete.

I don't know what to say, I have tried your sample on Windows Vista
and 7 and I see no border. Is there anyone else who can try Erwin's
sample on Windows (XP maybe?) and see if the behaviour is
reproducible?

Andrea.

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

···

On 7 February 2012 21:37, ErwinP wrote:

On 7 Feb., 08:38, Andrea Gavana <andrea.gav...@gmail.com> wrote:

I don't see it either on Win7, Py 2.7 and wx 2.9.3.1 and agw from SVN.

But if I hit to many times delete I see this exception:

Exception: invalid line index
File "h:\devProjectsT\aaTests\aaMisc\aaAndrea\ultimatelistctrl.py", line 54, in <module>
   app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 8651, in MainLoop
   wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 7943, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py", line 8062, in OnChar
   le.m_item = self.GetLine(self._current).GetItem(0, le.m_item)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py", line 6420, in GetLine
   self.CacheLineData(n)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py", line 6521, in CacheLineData
   ld = self.GetDummyLine()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py", line 6546, in GetDummyLine
   raise Exception("invalid line index")

Werner

···

On 09/02/2012 09:42, Andrea Gavana wrote:

Hi,

On 7 February 2012 21:37, ErwinP wrote:

Hi,

On 7 Feb., 08:38, Andrea Gavana<andrea.gav...@gmail.com> wrote:

Not that I can see, and it doesn't happen to me using AGW from SVN on
Windows Vista, wxPython 2.9.2.4. If you are using the standard AGW
distributed with wxPython, I would suggest to upgrade to 2.9 or to use
AGW from SVN.

I tried wx:2.9.3.1,agw:0.9.2 and I also copied the wx\lib\agw folder
from
SVN to this installation - with no sucess, the border is still visible
after delete.

I don't know what to say, I have tried your sample on Windows Vista
and 7 and I see no border. Is there anyone else who can try Erwin's
sample on Windows (XP maybe?) and see if the behaviour is
reproducible?

Hi

> I don't know what to say, I have tried your sample on Windows Vista
> and 7 and I see no border. Is there anyone else who can try Erwin's
> sample on Windows (XP maybe?) and see if the behaviour is
> reproducible?

I use Windows Vista SP1

But if I hit to many times delete I see this exception:
line 6546, in GetDummyLine
raise Exception("invalid line index")

I also get this exception. My first idea was that the reason is that
in my sample I don't check for negative item-counts.
So I changed the key-down-handler:
    def OnKeyDown(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_DELETE:
            if self.item_count > 0: #<=== new
                self.item_count -= 1
                self.ulc.SetItemCount(self.item_count)
        event.Skip()
But the exception comes before the key-down-handler is called with
item_count==0.

To clarify: the border is only displayed wrong when I delete the
*last* item.

Erwin

Hi Werner,

···

On 9 February 2012 14:38, werner wrote:

On 09/02/2012 09:42, Andrea Gavana wrote:

Hi,

On 7 February 2012 21:37, ErwinP wrote:

Hi,

On 7 Feb., 08:38, Andrea Gavana<andrea.gav...@gmail.com> wrote:

Not that I can see, and it doesn't happen to me using AGW from SVN on
Windows Vista, wxPython 2.9.2.4. If you are using the standard AGW
distributed with wxPython, I would suggest to upgrade to 2.9 or to use
AGW from SVN.

I tried wx:2.9.3.1,agw:0.9.2 and I also copied the wx\lib\agw folder
from
SVN to this installation - with no sucess, the border is still visible
after delete.

I don't know what to say, I have tried your sample on Windows Vista
and 7 and I see no border. Is there anyone else who can try Erwin's
sample on Windows (XP maybe?) and see if the behaviour is
reproducible?

I don't see it either on Win7, Py 2.7 and wx 2.9.3.1 and agw from SVN.

But if I hit to many times delete I see this exception:

Exception: invalid line index
File "h:\devProjectsT\aaTests\aaMisc\aaAndrea\ultimatelistctrl.py", line 54,
in <module>
app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 8651, in
MainLoop
wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 7943, in
MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py",
line 8062, in OnChar
le.m_item = self.GetLine(self._current).GetItem(0, le.m_item)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py",
line 6420, in GetLine
self.CacheLineData(n)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py",
line 6521, in CacheLineData
ld = self.GetDummyLine()
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\ultimatelistctrl.py",
line 6546, in GetDummyLine
raise Exception("invalid line index")

Thank you for reporting this, I have committed a fix in SVN.

Andrea.

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

Erwin,

Hi

I don't know what to say, I have tried your sample on Windows Vista
and 7 and I see no border. Is there anyone else who can try Erwin's
sample on Windows (XP maybe?) and see if the behaviour is
reproducible?

I use Windows Vista SP1

Maybe a Windows Vista listctrl issue?

But if I hit to many times delete I see this exception:
line 6546, in GetDummyLine
    raise Exception("invalid line index")

With latest SVN this one is corrected.

...

To clarify: the border is only displayed wrong when I delete the
*last* item.

I don't see the border after deleting the last item, but as mentioned before I am on Win 7.

Werner

···

On 09/02/2012 20:55, ErwinP wrote: