[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] =?utf-8?q?QsciScintilla_Lexer_disappears=3F?=
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2013-04-22 4:57:30
Message-ID: 28851296d236a1276ee48ffc8e783672 () localhost
[Download RAW message or body]

On Mon, 22 Apr 2013 05:21:25 +0430, Lee Harr <missive@hotmail.com> wrote:
> I am trying to use QsciScintilla in a project but I am having some
trouble
> with the Lexer. I don't understand why this code shows the lexer at
> the end of __init__ but when clicking in the margin it shows None.
> 
> Any thoughts?
> 
> 
> 
> import sys
> from PyQt4.QtCore import SIGNAL
> from PyQt4.QtGui import QApplication
> from PyQt4.Qsci import QsciScintilla, QsciLexerPython
> 
> 
> class SimplePythonEditor(QsciScintilla):
>     def __init__(self, parent=None):
>         super(SimplePythonEditor, self).__init__(parent)
> 
>         self.setMarginSensitivity(1, True)
>         self.connect(self,
>             SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
>             self.on_margin_clicked)
> 
>         lexer = QsciLexerPython()
>         self.setLexer(lexer)
>         print self.lexer()
> 
>     def on_margin_clicked(self, nmargin, nline, modifiers):
>         print self.lexer()
> 
> 
> if __name__ == "__main__":
>     app = QApplication(sys.argv)
>     editor = SimplePythonEditor()
>     editor.show()
>     app.exec_() 		 	   		  

Because setLexer() doesn't keep a reference to the lexer. Either give the
lexer a parent or keep an explicit reference.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic