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


Groups > comp.lang.python > #78790

Re: Syntax Highlighting in a tkinter Text widget

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: Syntax Highlighting in a tkinter Text widget
Date Tue, 07 Oct 2014 07:49:44 +0200
Organization A noiseless patient Spider
Lines 28
Message-ID <m0vut8$8mg$1@dont-email.me> (permalink)
References <43fe05d3-2892-44d0-9a1c-da6e7b7be2e5@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 7 Oct 2014 05:49:28 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="0ca390f552aaaca2fd2a25e51821864b"; logging-data="8912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bdRdPWja9Xmk3HWFJNEJlOEwLY+wZwUU="
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <43fe05d3-2892-44d0-9a1c-da6e7b7be2e5@googlegroups.com>
Cancel-Lock sha1:Vx/UCJyh0KYUbKiJBP7QgAapZ04=
Xref csiph.com comp.lang.python:78790

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web