View Full Version: syntax highlighting

C++ Learning Community > Other Programing Languages > syntax highlighting


Title: syntax highlighting
Description: in Python


Loki - August 7, 2004 01:59 AM (GMT)
I've recently picked up on learning Python (because i have since been too lazy to continue my ventures in C/C++). As an exercise, i decided to create a small Notepad - like program using the Tkinter module (once i get Fedora set up on my new hard drive i'll probably try out the GTK wrapper). Well, then i figured i'd go the extra mile and add a syntax highlighter (you know, just to see if i could). Well, that's about where i've been for the past hour or two. I was wondering if any of you had any ideas on how to do syntax highlighting. As i said before, i'm using the Tkinter module (here's a quick reference on it: http://www.pythonware.com/library/tkinter/introduction/). I'm guessing that i have to use tags (like text.tag_config("n", background="yellow", foreground="red")) but i'm not sure how to search for words and insert the tags. Any help is appreciated.

Loki - August 8, 2004 10:07 PM (GMT)
Never mind i figured it out.

KTC - August 8, 2004 11:11 PM (GMT)
Any chance you can let people here know how you're doing it ?

Loki - August 8, 2004 11:27 PM (GMT)
I decided to use the wxPython module instead of the (standard) Tkinter module. The wxPython module also comes with a set of Lexer functions that can be used with the StyledTextCtrl function. If anybody wants i'll post the source here.

Incubator - August 13, 2004 09:04 AM (GMT)
PyQT :D

use that cuz wxWindows seems to have some weird effects in Linux (font color or font type only changing when you type new text and not on the urrent selected text for example
and I dont like wxWindow's layout managment very much.

(Qt is so easy at that :P )

Loki - August 13, 2004 02:59 PM (GMT)
I'll check it out.
Thanks very much.




* Hosted for free by InvisionFree