Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 22:47, 12 October 2007.

How to make Python syntax coloring

From Forum Nokia Wiki


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.add(src[pos:start])
    t.color = color[tag]
    t.add(src[start:end])
    pos = end
t.color = 0
t.add(src[pos:])
 
app.body = t
e32.ao_sleep(10)

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

Related Discussions
Thread Thread Starter Forum Replies Last Post
Converting Python Images to Symbian Images for Wrappers yqmtooblue Python 4 2008-02-22 13:38
Guitar Tuner in Python cassioli Python 12 2008-02-02 11:20
nokia 6600,which python files to instal. orange1949 Python 3 2008-03-25 14:15
py2sis imank Python 1 2008-02-12 06:09
System error (-2) meet as soon as start Python Application wilen_ding Python 2 2007-09-13 19:32
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZpythonQ
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX