0

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!

fortran
  • 74,053
  • 25
  • 135
  • 175
  • 1
    What platform are you working on? I have noticed that wxPython is a whole lot slower on Linux than on Windows. – balpha Jun 29 '09 at 16:29
  • Linux... I could try it on windows to see if it gets better. – fortran Jun 29 '09 at 16:31
  • I've tested it on Windows and indeed faster (now it takes about half time, around 0.6s), but still is almost thirty times slower than the tkInter version :-s – fortran Jun 29 '09 at 16:53
  • Try posting to the wxPython-users group to see if Robin has any insight. I bet the gurus on there can get your code faster. http://groups.google.com/group/wxPython-users – DrBloodmoney Jun 29 '09 at 18:39
  • 3
    Have you tried using Freeze() and Thaw() to only update the display after you are done appending the coloured text? – mghie Jun 30 '09 at 07:20
  • will you post some sample code, so that we can tweak it and see – Anurag Uniyal Jul 01 '09 at 02:21
  • @mghie Thanks, I didn't know about these methods, that solved the problem! :-) – fortran Jul 01 '09 at 10:20

2 Answers2

1

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
  • 74,053
  • 25
  • 135
  • 175
0

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

Gareth Simpson
  • 36,943
  • 12
  • 47
  • 50