Discussion:
VListBox scrollbar changes as I scroll when using multi-line string items
Nathan McCorkle
2014-09-02 19:21:21 UTC
Permalink
I have been working on a widget like the Google Chrome URL search bar,
which not only lists items in a drop-down, but allows searching that list
and having the results displayed in real-time in the drop-down list.

Problems:
When I have word-wrap turned on for the text (long strings will wrap
instead of being cut-off), the scroll-bar changes size as I scroll down the
list. It seems like lines out-of-view are using a single line-height for
each item, but since the items can be multi-line, this is failing. I am not
storing the multi-line version, rather I'm recalculating on pop-up in case
the drop-down list changes width (i.e. frame was resized and drop-down got
wider).

Scrolling with the mouse-wheel doesn't work while the focus is in the
TextCtrl... I think this might be an easy fix.


Anyway, basically check the difference between the top drop-down (wordWrap
= False) and the lower drop-down (wordWrap=True)
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-02 19:46:12 UTC
Permalink
Hmm, this effect seems to happen on the VListBox.py demo file... in the
current demo (available on the wxpython site), as well as this seemingly
identical version (must be run from demo directory):
https://stuff.mit.edu/afs/sipb/project/python-lib/src/wxPython-src-2.5.3.1/wxPython/demo/VListBox.py

You can't see it very easily as this demo only changes by 1 pixel... so I
modified that demo slightly to show the effect. See attached and scroll the
left-hand list down, you'll see the scrollbar get smaller the further down
the list you scroll.
Post by Nathan McCorkle
I have been working on a widget like the Google Chrome URL search bar,
which not only lists items in a drop-down, but allows searching that list
and having the results displayed in real-time in the drop-down list.
When I have word-wrap turned on for the text (long strings will wrap
instead of being cut-off), the scroll-bar changes size as I scroll down the
list. It seems like lines out-of-view are using a single line-height for
each item, but since the items can be multi-line, this is failing. I am not
storing the multi-line version, rather I'm recalculating on pop-up in case
the drop-down list changes width (i.e. frame was resized and drop-down got
wider).
Scrolling with the mouse-wheel doesn't work while the focus is in the
TextCtrl... I think this might be an easy fix.
Anyway, basically check the difference between the top drop-down (wordWrap
= False) and the lower drop-down (wordWrap=True)
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-02 20:07:55 UTC
Permalink
Got the mousewheel to scroll, and added a timer to disable the mousehover
selection for 500 milliseconds after scrolling with mousewheel.

Still haven't figured out the scrollbar thing, though I did try calling
SetScrollbar(wx.VERTICAL, 0, 16, 50) on the VListBox and saw the scrollbar
change (then changed back as soon as I scrolled)...

I don't see any examples of people using SetScrollbar with VListBox
online... so I'm not sure when I should be determining the range and size
though (i.e. which event should I do this in?).

http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.Window.html#SetScrollbar
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robin Dunn
2014-09-24 01:03:17 UTC
Permalink
Post by Nathan McCorkle
Got the mousewheel to scroll, and added a timer to disable the
mousehover selection for 500 milliseconds after scrolling with mousewheel.
Still haven't figured out the scrollbar thing, though I did try calling
SetScrollbar(wx.VERTICAL,0,16,50) on the VListBox and saw the scrollbar
change (then changed back as soon as I scrolled)...
I don't see any examples of people using SetScrollbar with VListBox
online... so I'm not sure when I should be determining the range and
size though (i.e. which event should I do this in?).
You shouldn't need to, the VScrolledWindow and derived classes take care
of the scrollbar themselves, and so they reset it to what they think it
should be after you've set it to what you think it should be.

I think your problem stems from the fact that you don't word-wrap the
lines until they are being shown, so the first pass that the VListBox
takes through the data is measuring everything at 1 line high. It's not
able to get the accurate measurements until it fetches the strings to
display, which is done on-demand when they come into view. If you were
able to provide the wrapped measurements from the very beginning then I
bet it would work the way you want it to. Otherwise having the
scrollbar adjust as items are scrolled into view isn't too terrible IMO.
--
Robin Dunn
Software Craftsman
http://wxPython.org
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...