I have a virtual list control (wx.LC_REPORT | wx.LC_VIRTUAL |
wx.SUNKEN_BORDER) to which I continuously add items (to the underlying
data structure) via a loop and wx.Yield(). Works like a charm in
GTK/Linux. Mostly works on MSW except that upon every SetItemCount(N),
the list control scrolls either to the top of the list, or to the first
selected cell if there is one.
That's disastrous because it makes it impossible to browse through the
list in order to select more items: every time I scroll down, the list
ctrl jumps back up!
On GTK/Linux, the scroll position stays right where it's at like what
you would expect.
I tried to get clever with GetTopItem() and EnsureVisible(), but of
course, EnsureVisible() only scrolls as far as it needs to, so the top
item ends up becoming the bottom. After several repetitions, we're back
to the top.
Unfortunately, there is no SetTopItem() method, or I would be set.
I have a virtual list control (wx.LC_REPORT | wx.LC_VIRTUAL | wx.SUNKEN_BORDER) to which I continuously add items (to the underlying data structure) via a loop and wx.Yield(). Works like a charm in GTK/Linux. Mostly works on MSW except that upon every SetItemCount(N), the list control scrolls either to the top of the list, or to the first selected cell if there is one.
That's disastrous because it makes it impossible to browse through the list in order to select more items: every time I scroll down, the list ctrl jumps back up!
Do you call SetItemCount that often?
On GTK/Linux, the scroll position stays right where it's at like what you would expect.
I tried to get clever with GetTopItem() and EnsureVisible(), but of course, EnsureVisible() only scrolls as far as it needs to, so the top item ends up becoming the bottom. After several repetitions, we're back to the top.
Unfortunately, there is no SetTopItem() method, or I would be set.
Anyone ever deal with this? Any suggestions?
I tried duplicating this in the demo, but I can't. Can you provide a small sample?
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Chuck Esterbrook wrote:
> I have a virtual list control (wx.LC_REPORT | wx.LC_VIRTUAL |
> wx.SUNKEN_BORDER) to which I continuously add items (to the
> underlying data structure) via a loop and wx.Yield(). Works like a
> charm in GTK/Linux. Mostly works on MSW except that upon every
> SetItemCount(N), the list control scrolls either to the top of the
> list, or to the first selected cell if there is one.
>
> That's disastrous because it makes it impossible to browse through
> the list in order to select more items: every time I scroll down,
> the list ctrl jumps back up!
Do you call SetItemCount that often?
40,000 items come in over 1-3 minutes. I'm calling SetItemCount about
twice a second, but even if it was once every 5 seconds, the sudden
jump would make the GUI unusable.
> On GTK/Linux, the scroll position stays right where it's at like
> what you would expect.
>
> I tried to get clever with GetTopItem() and EnsureVisible(), but of
> course, EnsureVisible() only scrolls as far as it needs to, so the
> top item ends up becoming the bottom. After several repetitions,
> we're back to the top.
>
> Unfortunately, there is no SetTopItem() method, or I would be set.
>
> Anyone ever deal with this? Any suggestions?
I tried duplicating this in the demo, but I can't. Can you provide a
small sample?
Will do. First, I'll try going non-virtual to see if that fixes the
problem. We'll see if ListCtrl can handle that many items.
···
On Monday 28 April 2003 12:29 pm, Robin Dunn wrote:
On GTK/Linux it works. You scan scroll down the list control as it is
being filled and select whatever items you like. Everything acts stable
and as the ListCtrl grows, the scroll position remains steady.
But on MS Windows, the list control keeps snapping back to
the top each time its count is set; thereby making it unusable.
On Monday 28 April 2003 12:29 pm, Robin Dunn wrote:
Chuck Esterbrook wrote:
> I have a virtual list control (wx.LC_REPORT | wx.LC_VIRTUAL |
> wx.SUNKEN_BORDER) to which I continuously add items (to the
> underlying data structure) via a loop and wx.Yield(). Works like a
> charm in GTK/Linux. Mostly works on MSW except that upon every
> SetItemCount(N), the list control scrolls either to the top of the
> list, or to the first selected cell if there is one.
>
> That's disastrous because it makes it impossible to browse through
> the list in order to select more items: every time I scroll down,
> the list ctrl jumps back up!
Do you call SetItemCount that often?
> On GTK/Linux, the scroll position stays right where it's at like
> what you would expect.
>
> I tried to get clever with GetTopItem() and EnsureVisible(), but of
> course, EnsureVisible() only scrolls as far as it needs to, so the
> top item ends up becoming the bottom. After several repetitions,
> we're back to the top.
>
> Unfortunately, there is no SetTopItem() method, or I would be set.
>
> Anyone ever deal with this? Any suggestions?
I tried duplicating this in the demo, but I can't. Can you provide a
small sample?
I have a virtual list control (wx.LC_REPORT | wx.LC_VIRTUAL |
wx.SUNKEN_BORDER) to which I continuously add items (to the
underlying data structure) via a loop and wx.Yield(). Works like a
charm in GTK/Linux. Mostly works on MSW except that upon every
SetItemCount(N), the list control scrolls either to the top of the
list, or to the first selected cell if there is one.
That's disastrous because it makes it impossible to browse through
the list in order to select more items: every time I scroll down,
the list ctrl jumps back up!
Do you call SetItemCount that often?
On GTK/Linux, the scroll position stays right where it's at like
what you would expect.
I tried to get clever with GetTopItem() and EnsureVisible(), but of
course, EnsureVisible() only scrolls as far as it needs to, so the
top item ends up becoming the bottom. After several repetitions,
we're back to the top.
Unfortunately, there is no SetTopItem() method, or I would be set.
Anyone ever deal with this? Any suggestions?
I tried duplicating this in the demo, but I can't. Can you provide a
small sample?
Attached.
On GTK/Linux it works. You scan scroll down the list control as it is being filled and select whatever items you like. Everything acts stable and as the ListCtrl grows, the scroll position remains steady.
But on MS Windows, the list control keeps snapping back to
the top each time its count is set; thereby making it unusable.
There is a flag that should be passed to the windows API that will prevent the scrolling from being reset, I'll make the change. In the meantime you can reduce the problem somewhat by doing a lc.GetTopItem before and a lc.EnsureVisible after the SetItemCount.
Don't know about Mac...
It uses the same listctl code that wxGTK does so it should be fine.
# let the user scroll, select items, etc. ...
wxGetApp().Yield(True)
BTW, this is probably the cause of the app not exiting that you mention in the comments. If you never let the control flow to go back to the loop in ShowModal then it can't exit. It would be much better for the data to be fetched and processed in idle handlers or in an alternate thread so control can return to the MainLoop or ShowModal loop as much as possible. Yield should be used sparingly (or not at all according to some folks.)
···
On Monday 28 April 2003 12:29 pm, Robin Dunn wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Chuck Esterbrook wrote:
> But on MS Windows, the list control keeps snapping back to
> the top each time its count is set; thereby making it unusable.
There is a flag that should be passed to the windows API that will
prevent the scrolling from being reset, I'll make the change. In
the meantime you can reduce the problem somewhat by doing a
lc.GetTopItem before and a lc.EnsureVisible after the SetItemCount.
Thanks. That reduces the problem, but I get some weird behavior. Like
before a selection is ever made, the list will still scroll up, but in
small increments. Once I select an item, that behavior goes away, until
I resize the window.
Hopefully I'll be building wxPython from source soon and I'll just grab
the patch out of cvs!
> # let the user scroll, select items, etc. ...
> wxGetApp().Yield(True)
BTW, this is probably the cause of the app not exiting that you
mention in the comments. If you never let the control flow to go
back to the loop in ShowModal then it can't exit. It would be much
better for the data to be fetched and processed in idle handlers or
in an alternate thread so control can return to the MainLoop or
ShowModal loop as much as possible. Yield should be used sparingly
(or not at all according to some folks.)
Hmmm, doesn't wxGetApp().Yield(True) return? I can't see why the control
flow doesn't go back, but then maybe the biggest trouble with Yield()
is understanding it. I'll switch to something else.
# let the user scroll, select items, etc. ...
wxGetApp().Yield(True)
BTW, this is probably the cause of the app not exiting that you
mention in the comments. If you never let the control flow to go
back to the loop in ShowModal then it can't exit. It would be much
better for the data to be fetched and processed in idle handlers or
in an alternate thread so control can return to the MainLoop or
ShowModal loop as much as possible. Yield should be used sparingly
(or not at all according to some folks.)
Hmmm, doesn't wxGetApp().Yield(True) return? I can't see why the control flow doesn't go back, but then maybe the biggest trouble with Yield() is understanding it. I'll switch to something else.
Sorry, I should have quoted more code. The fact that the function that calls Yeild is called from the midst of a "for i in range(2000000):" loop means that it will be a long time until control gets back to the main loop. (I realize this is a somewhat contrived example...) Yield does return, but only when the event queue becomes empty so in a very busy app it is possible that it could take a long time to return too.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Hmmm (still), my code sets that self.shouldStop flag and the loop breaks
if that is true. So I still don't know why the program has trouble
exiting... I'll just switch my code to a background thread and
wxCallAfter() the results back into the main loop.
···
On Monday 05 May 2003 04:26 pm, Robin Dunn wrote:
Sorry, I should have quoted more code. The fact that the function
that calls Yeild is called from the midst of a "for i in
range(2000000):" loop means that it will be a long time until
control gets back to the main loop. (I realize this is a somewhat
contrived example...) Yield does return, but only when the event
queue becomes empty so in a very busy app it is possible that it
could take a long time to return too.