Forum: Poser Python Scripting


Subject: How can I speed up loading text into wx.TreeCtrl and wx.TextCtrl?

PhilC opened this issue on Apr 09, 2011 · 3 posts


PhilC posted Sat, 09 April 2011 at 11:20 AM

Question for y'all.

How can I speed up loading text into wx.TreeCtrl and wx.TextCtrl?

I'm using a basic while i < len(lines) loop.
Text is being appended in blocks of 10000 lines
Tree is being appended node by node.

Thanks.


nruddock posted Sat, 09 April 2011 at 12:55 PM

For trees, the best you can do using the standard control is to delay loading of child nodes until the node is expanded.

The true solution for large amounts of data is to use either the VirtualTree mix-in -> http://www.wxpython.org/docs/api/wx.lib.mixins.treemixin.VirtualTree-class.html or  the mvctree module -> http://www.wxpython.org/docs/api/wx.lib.mvctree-module.html allowing you to store data in a convenient (and more appropriate) structure.

For text, there doesn't seem to be anything equivalent, but you might find that the StyledTextCtrl -> http://www.wxpython.org/docs/api/wx.stc-module.html is better suited (although anything thing that isn't virtualised won't cope well with huge amounts of text).
The closest thing is the DataViewCtrl -> http://docs.wxwidgets.org/stable/wx_wxdataviewctrl.html#wxdataviewctrl (which only deals with list data in wx2.8, but will have a tree variant in wx2.9)


PhilC posted Sat, 09 April 2011 at 1:01 PM

Thanks, I'll look into that.