gtk/qt scintilla help !
fabien
fabienhenon_nospam_ at free.fr
Mon May 2 06:50:44 EDT 2005
John Ridley wrote:
> fabien wrote on Sun, 01 May 2005 05:40:05 -0700:
>
Hello John,
>
>>Hi,
>
>
> Hello Fabien
>
>
>>I am writing a POV-RAY editor with Python using
>>either QT or GTK as GUI 'wrapper'. ( I am still trying both )
>>
>>[snip]
>>
>>I have also downloaded qscintilla-1.62-gpl-1.5.1.
>>As for GTK, I also found the LexPOV.cpp file, with
>>no POV keywords in it and with no POV keywords in
>>any of the file in the package.
>>The compilation builds then move the library
>>libqscintilla.so to /usr/lib/qt3/lib.
>>
>>How do I link the newly built library to the folling qt script :
>>
>>[snip]
>
>
> QScintilla is a port to Qt of the Scintilla editor control, and PyQt
> provides the python bindings for it. Scintilla has several dozen lexers
> (including one for POV), and QScintilla currently provides class
> wrappers for a small selection of them - but not POV, as you will see
> from the documentation:
>
> http://www.river-bank.demon.co.uk/docs/qscintilla/hierarchy.html
>
> Given this, there are two routes you can go down. You could ask the
> developer of QScintilla to provide support for POV by making a request
> via the mailing list:
>
> http://www.riverbankcomputing.co.uk/pyqt/mailinglist.php
>
> Or you could write your own POV lexer class in python using the
> existing QScintilla APIs. This is not particularly difficult, but it
> does take some working out. As you already know, a list of POV keywords
> is required. You will then need to look at the source (LexPOV.cpp and
> SciLexer.h) to see how the keywords are used and how the lexical states
> tie up with the SCE_POV enum. QScintilla's lexer classes are mainly
> wrappers around this information, so once you've worked it out, writing
> a python class based on QextScintillaLexer is fairly straightforward:
Well I have tried to use two files called "qextscintillalexerlua.cpp"
and "qextsinctillalexerlua.h". I noticed that the LUA language used the
same type of syntax as for POV. I copied them both to
qextscintillalexerpov and replaced all the keywords found in them with
POV-keywords.
I compiled and it worked : I got a libqscintilla.so that was modified in
/usr/lib/qt3/lib.
The hitch is that a scintilla PYQT script also needs a file called
/usr/share/sip/qextscintillalexerperl.sip ( here for perl ).
I do not have a clue how to build a qextscintillalexerpov.sip file.
I looked at: http://www.river-bank.demon.co.uk/docs/sip/sipref.html
but it is all chinese to me. A do not know C.
-> This is where I am going to contact river-bank for information.
>
>
>>>>class LexerPOV(QextScintillaLexer):
>>>> def __init__(self, parent, name):
>>>> QextScintillaLexer.__init__(self, parent, name)
>>>> def lexer(self):
>>>> return "pov"
>>>> def color(self, style):
>>>> # styles map to (SCE_POV enum)
>>>> # return your own QColor
>>>> # or return the base class default
>>>> return QextScintillaLexer.color(self, style)
>>>> def keywords(self, set):
>>>> # if set == 0:
>>>> # return <pov keywords>
>>>> # elif ...
>>>> return 0
>>>> def description(self, style):
>>>> # if style == 0:
>>>> # return self.tr("Default")
>>>> # elif ...
>>>> return QString.null
>
>
Thanks for the example and for the information
Fabien
to reply, remove '_nospam_'
> Of course, this is a minimal lexer class - it is possible to be a lot
> more sophisticated than what is suggested here.
>
>
> John Ridley
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
More information about the Python-list
mailing list