[PyKDE] QSyntaxHighlighter issues

Eli Yukelzon reflog at gmail.com
Sat Sep 25 16:11:20 BST 2004


Awesome! Thanks everybody!


On Sat, 25 Sep 2004 06:51:26 -0700 (PDT), stuff at mailzilla.net
<stuff at mailzilla.net> wrote:
> 
> Try passing "self" into the constructor of the base class (ie. __init__
> method) in the constructor of your derived classes.
> 
> Change this:
>         QSyntaxHighlighter(edit)
> to:
>         QSyntaxHighlighter.__init__(self, edit)
> 
> and:
>         QTextEdit(parent,name)
> to:
>         QTextEdit.__init__(self, parent,name)
> 
> Hope this helps,
> 
> Phil Schwartz
> 
> On Sat, 25 Sep 2004, Eli Yukelzon wrote:
> 
> > Hi there.
> > I'm trying to implement a HTML tag highlighting in QTextEdit
> > I've subclassed the QSyntaxHighlighter and QTextEdit like this:
> >
> > class qh(QSyntaxHighlighter):
> >       def QSyntaxHighlighter(edit)
> 
> 
> >               QSyntaxHighlighter(edit)
> >
> >       def highlightParagraph( text, lastPara ):
> >               regexp = re.compile( r'^([\\w-]+:\\s)')
> >               if( regexp.search( text ) != -1 ):
> >                       font = textEdit().currentFont()
> >                       font.setBold( True )
> >                       self.setFormat( 0, regexp.matchedLength(), font )
> >
> >               return 0
> >
> > class te(QTextEdit):
> >       def __init__ (self,parent = 0, name = ""):
> >               QTextEdit(parent,name)
> >               #self.setTextFormat( Qt.PlainText )
> >               self.sh = qh(self)
> >
> > but on startup i get this exception:
> > attributeError, sipThis
> > in QSyntaxHighlighter constructor.
> >
> > What am i doing wrong? Maybe someone already implemented this, and I'm
> > just reinventing the wheel?
> >
> 
> 



-- 
To err is human, to really screw things up - you need a computer.




More information about the PyQt mailing list