views:

420

answers:

2

I've made a small tool that parses a chunk of text, does some simple processing (retrieves values from a dictionary, a few regex, etc.) and then spits the results.

In order to make easier to read the results, I made two graphic ports, one with tkInter and other with wxPython, so the output is nicely displayed in a Text Area with some words having different colours.

The tkInter implementation uses Tkinter.Text object and to apply the colours to the words uses tags (configured with the method Tkinter.Text.tag_config and passing them to Tkinter.Text.insert), and the measured while outputting about 400 different coloured words is < 0.02s.

The wxPython implementation uses wx.richtext.RichTextCtrl and to apply the colours to the words uses wx.richtext.RichTextCtrl.BeginTextColour and then wx.richtext.RichTextCtrl.AppendText; the performance is ridiculous, it takes abut 1.4s to do the same job that only took 0.02s to the tkInter port.

Is this an intrinsic problem of the RichTextCtrl widget, the wxPython bindings, or there is some way to speed it up?

Thanks!

A: 

It kind of avoids the question slightly, but could you use wxStyledTextCtrl instead?

Gareth Simpson
+1  A: 

I'm copying here the comment that solved the problem:

Have you tried using Freeze() and Thaw() to only update the display after you are done appending the coloured text? – mghie Jun 30 at 7:20

fortran