views:

220

answers:

4

Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .

+8  A: 

Other than pygments? http://pygments.org/

S.Lott
how could I make use of pygments in a GUI application?
Geo
Pygments can output to HTML or RTF. Just use a GUI widget that can render either of those.
Kamil Kisiel
Could you post a link to a widget that can render html?
Geo
Also it's not particularly hard to hack a Pango outputter for putting Pygments output straight into GTK Widgets.
Ali A
You could also write a custom formatter to output syntax highlighting in whatever format your widget needs.
Benjamin Peterson
+1  A: 

If you're using gtk+, there's a binding of gtksourceview for Python in gnome-python-extras. It seems to work well in my experience. The downside: the documentation is less than perfect.

There's also a binding of QScintilla for Python if PyQt is your thing.

Jason Baker
I tried QScintilla. Exactly what I needed!
Geo
+1  A: 

You can use StyledTextCtrl in wxPython. Check out the official demo for an example (The demo code tab for any demo).

Toni Ruža
A: 

You say "in a GUI app" but don't mention the toolkit.

If you are using PyQt, and need a read-only widget, you can use QWebKit which has a whole HTML widget in it based on WebKit, so it supports pretty much anything, from flash to the ACID2 test.

If you want a read-write widget, Qt's QTextEdit supports syntax highlighting, and I wrote an adapter to let pygments worj with it:

http://lateral.netmanagers.com.ar/weblog/2009/09/21.html#BB831

I am sure something similar can be done with other toolkits, but I don't know how.

Roberto Alsina