Archived:How to make PySymbian syntax coloring

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Created: cyke64 (15 Mar 2007)
Last edited: hamishwillee (31 May 2013)

You first need to install the pyfontify module for making simple syntax coloring in Text widget. And with Eclipse you can use Pydev, very convenient feature rich plugin.

from appuifw import *
from pyfontify import fontify
import os, e32
src = ur"""
__version__ = "0.4"
import string, re, keyword
commentPat = "#.*"
# Build up a regular expression
pat = "q[^\q\n]*(\\\\[\000-\377][^\q\n]*)*q"

color = { 'keyword': 0x0000ff,
'string': 0xff00ff,
'comment': 0x008000,
'function': 0x008080,
'class': 0x008080 }
t = Text()
pos = 0
for tag, start, end, sl in fontify(src):
t.color = 0
t.color = color[tag]
pos = end
t.color = 0
app.body = t

Issue : This is very slow ! 1 minute for hundred python source lines !

This page was last modified on 31 May 2013, at 01:04.
24 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.