473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

gtk/qt scintilla help !

Hi,

I am writing a POV-RAY editor with Python using either QT or GTK as GUI
'wrapper'. ( I am still trying both )

* * * * PYGTK * * * *
I have downloaded PygtkScintilla-1.99.5.
There is a lexPOV.cxx file in the package, but I can not find any POV
keywords in any file ( there are about 150 POV keywords). Did i miss it,
and if not, how do I create one and include it for the library building ?

Anyway, I compiled pyscintilla and got a library file called 'scintilla.a'.
Now how do I link the scintilla.a library to this GTK script example :

8<--------------- snip ------------>8

import pygtk
pygtk.require('2.0')
import gtk
import scintilla
class GUI:
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)

window.set_title("Pyvon")

window.connect("destroy", lambda w:gtk.main_quit())

table = gtk.Table(10,10)

# Here we connect notifications as they are gtk signals as well
editor = scintilla.Scintilla()
#s.connect("CharAdded", char_added_notif)
window.add(table)
table.add(editor)
editor.show()
window.set_size_request(200, 300)
window.show_all()
def main():
gtk.main()
return 0

if __name__ == "__main__":
GUI()
main()
8<--------------- snip ------------>8

The same goes for QT :

* * * * PYQT * * * *
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 :
8<--------------- snip ------------>8

import sys, string
from qt import *
from qtext import *
fileopen = [
'16 13 5 1',
'. c #040404',
'# c #808304',
'a c None',
'b c #f3f704',
'c c #f3f7f3',
'aaaaaaaaa...aaaa',
'aaaaaaaa.aaa.a.a',
'aaaaaaaaaaaaa..a',
'a...aaaaaaaa...a',
'.bcb.......aaaaa',
'.cbcbcbcbc.aaaaa',
'.bcbcbcbcb.aaaaa',
'.cbcb...........',
'.bcb.#########.a',
'.cb.#########.aa',
'.b.#########.aaa',
'..#########.aaaa',
'...........aaaaa'
]

filesave = [
'14 14 4 1',
'. c #040404',
'# c #808304',
'a c #bfc2bf',
'b c None',
'..............',
'.#.aaaaaaaa.a.',
'.#.aaaaaaaa...',
'.#.aaaaaaaa.#.',
'.#.aaaaaaaa.#.',
'.#.aaaaaaaa.#.',
'.#.aaaaaaaa.#.',
'.##........##.',
'.############.',
'.##.........#.',
'.##......aa.#.',
'.##......aa.#.',
'.##......aa.#.',
'b.............'
]

fileprint = [
'16 14 6 1',
'. c #000000',
'# c #848284',
'a c #c6c3c6',
'b c #ffff00',
'c c #ffffff',
'd c None',
'ddddd.........dd',
'dddd.cccccccc.dd',
'dddd.c.....c.ddd',
'ddd.cccccccc.ddd',
'ddd.c.....c....d',
'dd.cccccccc.a.a.',
'd..........a.a..',
'.aaaaaaaaaa.a.a.',
'.............aa.',
'.aaaaaa###aa.a.d',
'.aaaaaabbbaa...d',
'.............a.d',
'd.aaaaaaaaa.a.dd',
'dd...........ddd'
]
fileOpenText = \
'''<img source="fileopen">
Click this button to open a <em>new file</em>.<br><br>
You can also select the <b>Open</b> command from the <b>File</b> menu.'''

fileSaveText = \
'''Click this button to save the file you are editing.<br><br>
You will be prompted for a filename.<br><br>
You can also select the <b>Save</b> command from the <b>File</b> menu.'''

filePrintText = \
'''Click this button to print the file you are editing.<br><br>
You can also select the <b>Print</b> command from the <b>File</b> menu.'''
editorList = []
class QSci(QextScintilla):
def __init__(self,parent):
QextScintilla.__init__(self,parent)

self.setUtf8(1)

#lex = QextScintillaLexerPython(self)
#QextScintillaLexerCPP
#lex = QextScintillaLexerCPP(self)
#lex = QextScintillaLexerPov(self)
lex = QextScintillalexerCSharp(self)
self.setLexer(lex)

self.setBraceMatching(QextScintilla.SloppyBraceMat ch)
self.setAutoIndent(1)
self.setIndentationWidth(4)
self.setIndentationGuides(1)
self.setIndentationsUseTabs(0)
self.setAutoCompletionThreshold(1)

class ApplicationWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self,None,'example application main
window',Qt.WDestructiveClose)

self.filename = QString.null
self.printer = QPrinter()

self.fileTools = QToolBar(self,'file operations')

openIcon = QPixmap(fileopen)
self.fileOpen = QToolButton(QIconSet(openIcon),'Open
File',QString.null,self.load,self.fileTools,'open file')

saveIcon = QPixmap(filesave)
self.fileSave = QToolButton(QIconSet(saveIcon),'Save
File',QString.null,self.save,self.fileTools,'save file')

printIcon = QPixmap(fileprint)
self.filePrint = QToolButton(QIconSet(printIcon),'Print
File',QString.null,self.printDoc,self.fileTools,'p rint file')

QWhatsThis.whatsThisButton(self.fileTools)

QWhatsThis.add(self.fileOpen,fileOpenText)
QMimeSourceFactory.defaultFactory().setPixmap('fil eopen',openIcon)
QWhatsThis.add(self.fileSave,fileSaveText)
QWhatsThis.add(self.filePrint,filePrintText)

self.file = QPopupMenu(self)
self.menuBar().insertItem('&File',self.file)

self.file.insertItem('&New',self.newDoc,Qt.CTRL + Qt.Key_N)

id =
self.file.insertItem(QIconSet(openIcon),'&Open',se lf.load,Qt.CTRL +
Qt.Key_O)
self.file.setWhatsThis(id,fileOpenText)

id =
self.file.insertItem(QIconSet(saveIcon),'&Save',se lf.save,Qt.CTRL +
Qt.Key_S)
self.file.setWhatsThis(id,fileSaveText)

id = self.file.insertItem('Save &as',self.saveAs)
self.file.setWhatsThis(id,fileSaveText)

self.file.insertSeparator()

id =
self.file.insertItem(QIconSet(printIcon),'&Print', self.printDoc,Qt.CTRL
+ Qt.Key_P)
self.file.setWhatsThis(id,filePrintText)

self.file.insertSeparator()

self.file.insertItem('&Close',self,SLOT('close()') ,Qt.CTRL +
Qt.Key_W)

self.file.insertItem('&Quit',qApp,SLOT('closeAllWi ndows()'),Qt.CTRL +
Qt.Key_Q)

self.view = QPopupMenu(self)
self.menuBar().insertSeparator()
self.menuBar().insertItem('&View',self.view)
self.view.insertItem('Split',self.split)

self.help = QPopupMenu(self)
self.menuBar().insertSeparator()
self.menuBar().insertItem('&Help',self.help)

self.help.insertItem('&About',self.about,Qt.Key_F1 )
self.help.insertItem('About &Qt',self.aboutQt)

self.splitter = QSplitter(self)
self.e = QSci(self.splitter)
self.e.setFocus()
self.setCentralWidget(self.splitter)

self.statusBar().message('Ready',2000)
self.resize(450,600)

def split(self):
ssci = QSci(self.splitter)
ssci.setDocument(self.e.document())
ssci.show()

def newDoc(self):
ed = ApplicationWindow()
ed.show()
editorList.append(ed)

def load(self):
fn = QFileDialog.getOpenFileName(QString.null,QString.n ull,self)
if fn.isEmpty():
self.statusBar().message('Loading aborted',2000)
return

fileName = str(fn)

self.e.clear()

try:
f = open(fileName,'r')
except:
return

for l in f.readlines():
self.e.append(l)

f.close()

self.setCaption(fileName)
self.statusBar().message('Loaded document %s' % (fileName),2000)

def save(self):
if self.filename.isEmpty():
self.saveAs()
return

try:
f = open(str(self.filename),'w+')
except:
self.statusBar().message('Could not write to %s' %
(self.filename),2000)
return

f.write(str(self.e.text()))
f.close()

self.e.setEdited(0)
self.setCaption(self.filename)
self.statusBar().message('File %s saved' % (self.filename),2000)

def saveAs(self):
fn = QFileDialog.getSaveFileName(QString.null,QString.n ull,self)
if not fn.isEmpty():
self.filename = fn
self.save()
else:
self.statusBar().message('Saving aborted',2000)

def printDoc(self):
Margin = 10
pageNo = 1

if self.printer.setup(self):
self.statusBar().message('Printing...')

p = QPainter()
p.begin(self.printer)
p.setFont(self.e.font())
yPos = 0
fm = p.fontMetrics()
metrics = QPaintDeviceMetrics(self.printer)

for i in range(self.e.numLines):
if Margin + yPos > metrics.height() - Margin:
pageNo = pageNo + 1
self.statusBar().message('Printing (page %d)...' %
(pageNo))
self.printer.newPage()
yPos = 0

p.drawText(Margin,Margin +
yPos,metrics.width(),fm.lineSpacing(),Qt.ExpandTab s |
Qt.DontClip,self.e.textLine(i))
yPos = yPos + fm.lineSpacing()

p.end()
self.statusBar().message('Printing completed',2000)
else:
self.statusBar().message('Printing aborted',2000)

def closeEvent(self,ce):
if not self.e.isModified():
ce.accept()
return

rc = QMessageBox.information(self,'QScintilla Editor',
'The document has been changed since the last save.',
'Save Now','Cancel','Leave Anyway',0,1)

if rc == 0:
self.save()
ce.accept()
elif rc == 2:
ce.accept()
else:
ce.ignore()

def about(self):
QMessageBox.about(self,'QScintilla Editor',
'This is a framework for testing QScintilla.')

def aboutQt(self):
QMessageBox.aboutQt(self,'QScintilla Editor')
a = QApplication(sys.argv)
mw = ApplicationWindow()
mw.setCaption('Document 1')
mw.show()
a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
a.exec_loop()

8<--------------- snip ------------>8
Thank you for any help
Jul 19 '05 #1
2 3527
Fabien:
There is a lexPOV.cxx file in the package, but I can not find any POV
keywords in any file ( there are about 150 POV keywords). Did i miss it,
and if not, how do I create one and include it for the library building ?


The Scintilla web site, documentation and mailing list are:
http://www.scintilla.org/
http://scintilla.sourceforge.net/ScintillaDoc.html
http://mailman.lyra.org/mailman/list...tilla-interest

Keyword lists are often very large as it is frequently desired to
highlight all the identifiers in an API. The Win32 API is around 10
megabytes in SciTE .api format.

The SciTE editor is shipped with some keyword lists, including some
for POV in the pov.properties file.

To set keywords, call SCI_SETKEYWORDS as described on the
documentation page.

I do not personally use the Qt or PygtkScintilla wrappers for
Scintilla.

Neil
Jul 19 '05 #2
Neil Hodgson wrote:
Fabien:

There is a lexPOV.cxx file in the package, but I can not find any POV
keywords in any file ( there are about 150 POV keywords). Did i miss it,
and if not, how do I create one and include it for the library building ?

The Scintilla web site, documentation and mailing list are:
http://www.scintilla.org/
http://scintilla.sourceforge.net/ScintillaDoc.html
http://mailman.lyra.org/mailman/list...tilla-interest

Keyword lists are often very large as it is frequently desired to
highlight all the identifiers in an API. The Win32 API is around 10
megabytes in SciTE .api format.

The SciTE editor is shipped with some keyword lists, including some
for POV in the pov.properties file.

Yes I saw that file, but as far as I know, it is used by and only by
SciTE. I thought at first that I could use it for pygtkScintilla.

To set keywords, call SCI_SETKEYWORDS as described on the
documentation page. That is going to be tough, I do not know anything about C. It is going
to be easier if I could find a file with a syntax close to that of POV
and replace of the keywords found in it with POV keywords ,and the compile.

I do not personally use the Qt or PygtkScintilla wrappers for
Scintilla.
Thanks for the reply and the links

Fabien
Neil

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: manders2k | last post by:
Hi all -- I'm contemplating the idea of writing a simple emacs-like editor in python (for fun and the experience of doing so). In reading through Craig Finseth's "The Craft of Text Editing": ...
1
by: Nuff Said | last post by:
Question: Is there a way to unfold a Python class *without* unfolding all its methods etc. so that you can get a quick overview of the class? Details: I normally open a file either with...
14
by: Bulba! | last post by:
One of the posters inspired me to do profiling on my newbie script (pasted below). After measurements I have found that the speed of Python, at least in the area where my script works, is...
2
by: Kirk Larsen | last post by:
I am at a loss as to how to get Scintilla to work in a VB.Net app. Any ideas or places where I could go look?
0
by: Marcin Podle¶ny | last post by:
Hi, Have you ever used Scintilla in vb.net application? If so - give me some informations how to do it, please. Thanks Marcin
5
by: Just call me James | last post by:
Hi, Coming away from the luxury of the delphi IDE has been something of a shock. As a consequence I've become aware that maybe I need to spend some money on a python IDE. As a beginner I...
14
by: Bit Byte | last post by:
I am looking for a (free) IDE for PHP5 development. I am currently using emac/vim (on Linux) and EditPlus on Windows. But I terribly miss features like: 1. Ability to debug code (i.e. step...
1
by: Terry Olsen | last post by:
I'm using the SciLexer.dll to write a code editor for an in-house scripting language. I have the editor window up on a form but I need to use it's API. I've used the following commands to load the...
3
by: Till Kranz | last post by:
Hi, I tried to get started with Boost.Python. unfortunately I never used the bjam build system before. As it is explained in the documentation I tried to adapt the the files form the examples...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.