Virtual listcontrol

Hi List,

I am trying to get a virtual list control working in such a way that it
interferes as little as possible with the rest of the program. This because
it should perform over a low bandwidth VPN.

First I define the columns, next I call the following routine and after that,
I define an ONIdle event that triggers this routine also.

    def __getRecordsVirtual(self, event=None):
        try:
            h = self.virt_cursor.fetchmany(20)
        except:
            return
        if len(h) == 20:
            if not event is None: event.RequestMore(True)
        elif self.Autocommit: Opendb.TableObjs.SQLDictdb.db.commit()
        self.pr += h
        self.SetItemCount(len(self.pr))
        while self.n < len(self.pr):
            self.StoreKeys(self.pr[self.n])
            self.n += 1

The problem is that the virtual control doesn't build. The OnGetItemText is
not called. Anyone has any idea's

Cheers,
D.Kniep

Dick Kniep wrote:

[...]

The problem is that the virtual control doesn't build. The OnGetItemText
is not called. Anyone has any idea's

Do you use the wxLC_VIRTUAL style?

Yep

Okay, is OnGetItemText not called at all, or not called after the OnIdle adds some more items to the list? Does calling self.RefreshItems(0, len(self.pr)) after the SetItemCount help?

···

On Tuesday 10 February 2004 01:46, Robin Dunn schreef: > >>Dick Kniep wrote:

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

Dick Kniep wrote:

[...]

The problem is that the virtual control doesn't build. The OnGetItemText
is not called. Anyone has any idea's

Do you use the wxLC_VIRTUAL style?

Yep

Okay, is OnGetItemText not called at all, or not called after the OnIdle
adds some more items to the list?

It is not called at all

Does calling self.RefreshItems(0, len(self.pr)) after the SetItemCount help?

No

Hmmm... Okay, if you can reproduce it in a small standalone sample then I'll be able to dig deeper.

But I have another question too. Is it worth while using OnIdle here, or is my solution not contributing to a better performance at all? I mean, now I am using Idle to read records from the database, but if I am doing a fetchmany in the "OnGetItemText", it will only read the records when they are needed. (So when I am scrolling down).

If you want to preload the records before scrolling then EVT_IDLE (or a timer, or a worker thread) is appropriate. Otherwise the user may notice a delay if they are not loaded until needed. You may also want to try using EVT_LIST_CACHE_HINT, I think it will send hints such that you are caching a bit ahead of the viewable lines.

···

On Tuesday 10 February 2004 23:28, Robin Dunn schreef: > >>Dick Kniep wrote:

On Tuesday 10 February 2004 01:46, Robin Dunn schreef: >>> >>>>Dick Kniep wrote:

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