On Mon, 25 Aug 2014 14:15:59 +0000
Vasilis Vlachoudis <vasilis.vlachou...@cern.ch> wrote:

> Hi all,
> 
> I am trying to implement a small g-code editor and real time viewer in
> tkinter. I am using the Text() widget as an editor, but I have troubles
> in highlighting the text during editing. Its slow when editing big
> files.
(...)

I don't have much experience with the text widget's advanced
capabilities, so I can just give a general hint on how to speed up
repeating tasks in Tkinter.
In my experience calls to Python commands are usually fast enough, the
bottleneck is the calls to Tk, though I am not sure if this is because Tk
is slow in itself or if it is the mechanism of the Tcl interpreter that
is somehow "embedded" into Python that makes things slow.
So as a rule of thumb I suggest that if you want to speed up things I
would try to eliminate as many of the calls to Tkinter widgets from the
repeating routine as possible.
If you want to track down which of these calls are particularly time
expensive sometimes it proved useful to add some calls to time.time() to
measure the duration a particular command took.
So my suggestion is to see, if you can store some of the information
about the tags that you query in your highlight() routine again and again
e.g. with the text widgets search() or compare() methods in a python list
or dictionary and access the information from there. This might
complicate parts of the code but will probably result in a remarkable
speed-up of your routine.

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Kirk to Enterprise -- beam down yeoman Rand and a six-pack.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to