Open GoogleCodeExporter opened 9 years ago
Also another speedup would be to only redraw items within the currently
scrolled-to
region.
Original comment by mackst...@gmail.com
on 2 Oct 2008 at 10:23
Uh, ignore that last comment. I'm a little sleep-deprived.
Here is another speedup which avoids checking the max width of all rendered
items for
every refresh:
in __init__:
self.maxItemWidth = None
in refresh:
- maxItemWidth = self.size[0]
- for item in self.items:
- itemWidth = self.style['font'].size(str(item))[0]
- if itemWidth > maxItemWidth:
- maxItemWidth = itemWidth
+ if self.maxItemWidth is None:
+ maxItemWidth = self.size[0]
+ for item in self.items:
+ itemWidth = self.style['font'].size(str(item))[0]
+ if itemWidth > maxItemWidth:
+ maxItemWidth = itemWidth
+
+ if self.style['autosize']:
+ self.size = maxItemWidth, len(self.items) * itemheight
+ self.maxItemWidth = maxItemWidth
- if self.style['autosize']:
- self.size = maxItemWidth, len(self.items) * itemheight
-
Original comment by mackst...@gmail.com
on 2 Oct 2008 at 10:41
Ok, one problem I've found is that when you change items dynamically, the new
plain_on_last_refresh list becomes out of sync with it. What I did was to work
around this to use a property so they both always stay in sync:
def set_items(self, items):
self._items = items
self.plain_on_last_refresh = [False] * len(items)
items = property(lambda self: self._items, set_items)
and remove this from __init__:
self.plain_on_last_refresh = [False] * len(items)
I can make a clean patch with all of this stuff combined if it would help.
Original comment by mackst...@gmail.com
on 3 Oct 2008 at 5:00
Original issue reported on code.google.com by
mackst...@gmail.com
on 2 Oct 2008 at 10:20Attachments: