Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78789 > unrolled thread

Syntax Highlighting in a tkinter Text widget

Started byNicholas Cannon <nicholascannon1@gmail.com>
First post2014-10-06 22:35 -0700
Last post2014-10-07 01:18 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Syntax Highlighting in a tkinter Text widget Nicholas Cannon <nicholascannon1@gmail.com> - 2014-10-06 22:35 -0700
    Re: Syntax Highlighting in a tkinter Text widget Christian Gollwitzer <auriocus@gmx.de> - 2014-10-07 07:49 +0200
    Re: Syntax Highlighting in a tkinter Text widget Nicholas Cannon <nicholascannon1@gmail.com> - 2014-10-07 01:18 -0700

#78789 — Syntax Highlighting in a tkinter Text widget

FromNicholas Cannon <nicholascannon1@gmail.com>
Date2014-10-06 22:35 -0700
SubjectSyntax Highlighting in a tkinter Text widget
Message-ID<43fe05d3-2892-44d0-9a1c-da6e7b7be2e5@googlegroups.com>
Hey guys Im working on an open source text editor(https://github.com/nicodasiko/Text-Config-2) and I would like to add syntax highlighting(mainly for python code). I have built the editor in python and the text input is a Text tkinter widget. I know how to add tags and highlight things  but Im not sure on how to constantly update the highlighting.

[toc] | [next] | [standalone]


#78790

FromChristian Gollwitzer <auriocus@gmx.de>
Date2014-10-07 07:49 +0200
Message-ID<m0vut8$8mg$1@dont-email.me>
In reply to#78789
Am 07.10.14 07:35, schrieb Nicholas Cannon:
> Hey guys Im working on an open source text
> editor(https://github.com/nicodasiko/Text-Config-2) and I would like
> to add syntax highlighting(mainly for python code). I have built the
> editor in python and the text input is a Text tkinter widget. I know
> how to add tags and highlight things  but Im not sure on how to
> constantly update the highlighting.

How long do you expect the input to be? If it will be short pieces, just 
run your regexps at every keystroke.

You can also cheat and use an existing tool for syntax highlighting. One 
possibility is the ctext widget, which is based on the text widget and 
is part of tcllib:

	http://tcllib.sourceforge.net/doc/ctext.html

All you need to do is to wrap it for the use in Tkinter.

Another alternative would be ScintillaTk

	http://sourceforge.net/projects/scintillatk/

Scintilla is a full-blown editor component, which is used in many code 
editors as the basic building block. Since this is a compiled extension, 
I have no idea how hard it will be to interface it with Python, however.

	Christian

[toc] | [prev] | [next] | [standalone]


#78793

FromNicholas Cannon <nicholascannon1@gmail.com>
Date2014-10-07 01:18 -0700
Message-ID<c424b5fa-15ed-4bee-8f51-bb676b8b1952@googlegroups.com>
In reply to#78789
Sweet thanks for the help many I am defiantly going to use these. 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web