[PyQt] call method doesn't work if it has QScintilla instance
I have a small problem in defining/calling an external method in my application. I have 3 files, mainapp.py, qscintilla.py and settings.py in mainapp.py: from qscintilla import sciEditor from settings import dialog in setting.py (settings dialog): from qscintilla import sciEditor in qscintilla.py: scintilla instances stuff the strange thing is that I can not call a method of sciEditor from settingdialog which has Qscintilla instance!! I try to be clearer: For example, in my sciEditor class I have these methods: def method1 (self): print "Hello" def method2 (self): self.SendScintilla (QsciScintilla.SCI_CLEARALL) self.setText ("Hello") calling the first method from settings dialog works, the latter not! maybe I'm missing something!!! Any suggest is appreciate ! All the best! -SL -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] [QScintilla] - changing font to editor by settings dialog
Hi Detlev and thank you for your quick reply, 2012/10/11 Detlev Offenbach > ** > > All stuff you asked for is used in the eric IDE. You may have a look at > the code or simply use it for your purpose. > > > I am working on development of a simple interactive python console [1] and I would like handle myself this settings by settings dialog base [2]. I am looking to ERIC code but I cannot find something help me ! Here [3] how I defined the settings for lexer ! How can I call pythonConsole/fontfamilytext key in readSettings and pass it to setDefaultFont method? and then How can I refresh properties for lexer so apply the changes ? simply self.lexer.refreshProperties() ?? Any advice is appreciate ! Regards, -SL [1] - http://lrssvt.ns0.it/img/console.png [2] - http://lrssvt.ns0.it/img/settings.png [3] - https://gist.github.com/3855242 > Regards, > > Detlev > > > On Thursday 11 October 2012, 14:33:48 Salvatore Larosa wrote: > > Hi all, > I would like to change font and fontsize (eventually API path too) in my > editor by using a setting dialog. > What I looking to do is on event click (accept) of settings dialog apply > the changes at the editor. > > Any hint ? > > Also, is there any useful resource on how can I use refreshProperties, > readSettings, writeSettings ? > > Thanks in advance ! > > -SL > > -- > Salvatore Larosa > linkedIn: http://linkedin.com/in/larosasalvatore > twitter: @lrssvt > skype: s.larosa > IRC: lrssvt on freenode > > > > -- > > Detlev Offenbach > > det...@die-offenbachs.de > -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [QScintilla] - changing font to editor by settings dialog
Hi all, I would like to change font and fontsize (eventually API path too) in my editor by using a setting dialog. What I looking to do is on event click (accept) of settings dialog apply the changes at the editor. Any hint ? Also, is there any useful resource on how can I use refreshProperties, readSettings, writeSettings ? Thanks in advance ! -SL -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi Phil and all, 2012/9/20 Salvatore Larosa > Hi Phil, > > 2012/9/20 Phil Thompson > >> On Thu, 20 Sep 2012 00:48:10 +0200, Salvatore Larosa >> wrote: >> > Hi, >> > >> > 2012/9/19 Phil Thompson >> > >> >> On Wed, 19 Sep 2012 14:54:57 +0200, Salvatore Larosa >> >> >> wrote: >> >> > Hi Phil, >> >> > >> >> > 2012/9/19 Phil Thompson >> >> > >> >> >> On Wed, 19 Sep 2012 08:05:42 +0200, Salvatore Larosa >> >> >> >> >> wrote: >> >> >> > Hi, >> >> >> > >> >> >> > 2012/9/19 Phil Thompson >> >> >> > >> >> >> >> On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa >> >> >> >> >> >> >> wrote: >> >> >> >> > Hi all, >> >> >> >> > I am not sure if this is the rigth place to ask! >> >> >> >> > >> >> >> >> > I created a small console to execute python command by using >> >> >> Qscintilla >> >> >> >> > python bindings but something doesnt work with MIME data. >> >> >> >> > >> >> >> >> > My code is: >> >> >> >> > >> >> >> >> > def fromMimeData(self, source): >> >> >> >> > if source.hasText(): >> >> >> >> > pasteList = QStringList() >> >> >> >> > pasteList = source.text().split("\n") >> >> >> >> > if (len(pasteList) > 1): >> >> >> >> > self.move_cursor_to_end() >> >> >> >> > for line in pasteList[:-1]: >> >> >> >> > self.append(line) >> >> >> >> > self.move_cursor_to_end() >> >> >> >> > self.runCommand(unicode(self.currentCommand())) >> >> >> >> > self.append(unicode(pasteList[-1])) >> >> >> >> > self.move_cursor_to_end() >> >> >> >> > >> >> >> >> > First question: when I paste some text in console and run >> command >> >> I >> >> >> >> > get: >> >> >> >> > >> >> >> >> > TypeError: invalid result type from PythonEdit.fromMimeData() >> >> >> >> > >> >> >> >> > How I can avoid it? >> >> >> >> >> >> >> >> fromMimeData() should return a 2-tuple of the text as a >> QByteArray >> >> and >> >> >> a >> >> >> >> bool set if the selection is rectangular. >> >> >> >> >> >> >> > >> >> >> > Thanks for your reply. >> >> >> > >> >> >> > oddly the paste command works well although returns that error! >> >> >> > how should I manage the contents of tuple? >> >> >> >> >> >> I don't know what your code is supposed to do. If your >> implementation >> >> of >> >> >> fromMimeData() is adding extra behaviour (rather than changing the >> >> >> default >> >> >> behaviour) then call the super-class implementation, ie. add the >> >> >> following >> >> >> at the end... >> >> >> >> >> >> return super(MyClass, self).fromMimeData(source) >> >> >> >> >> >> >> >> > That solve the problem about typeError, but now it paste twice the >> same >> >> > word! >> >> > You can see the source code here [1] (MIME data stuff is at line >> 418). >> >> >> >> The purpose of fromMimeData() is to allow you to specify how MIME data >> is >> >> converted to text. It looks like you are trying to use it for another >> >> purpose. You should probably look at reimplementing dropEvent() >> instead. >> >> >> >> >> > I thought it would work like insertFromMimeData [1]. >> > I tested it with QTextEdit widget and works fine! >> > >> > I need that to execute multi-line command in my shell i.e.: >> >>>> if True: >> > . . .print "Hello" >> > . . . if False: >> > . . .print "Bye Bye" >> > >> > so the last command line only paste the text doesnt run it! >> > >> > Also, I implemented dropEvent() and has worked only for drag and drop >> event >> > and not to paste :-( >> >> So reimplement paste(). >> >> > As you can see from the video [1] operations paste and drop works fine. > However, with this configuration [2] I can not paste or drop a piece of > text to a specific position of the cursor is the clipboard and mimedataare > inserted at > the end of the line! You can also see this problem in the video! > Thanks for your time!! > > Anyway, if you can not replicate it, apparently it's just my problem! > I can send you the source code (a simple widget) so that you can replicate > it! > > Regards, > > -SL > > [1] - http://lrssvt.ns0.it/pasteDropMimeData.ogv > [2] - https://gist.github.com/3755609 > I soved simply changing self.append() to self.insert() in insertFromDropPaste() method! The "append()" method inserts the text to the end of the text edit [1] Cheers! [1] - http://goo.gl/yGWkE -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi Phil, 2012/9/20 Phil Thompson > On Thu, 20 Sep 2012 00:48:10 +0200, Salvatore Larosa > wrote: > > Hi, > > > > 2012/9/19 Phil Thompson > > > >> On Wed, 19 Sep 2012 14:54:57 +0200, Salvatore Larosa > > >> wrote: > >> > Hi Phil, > >> > > >> > 2012/9/19 Phil Thompson > >> > > >> >> On Wed, 19 Sep 2012 08:05:42 +0200, Salvatore Larosa > >> > >> >> wrote: > >> >> > Hi, > >> >> > > >> >> > 2012/9/19 Phil Thompson > >> >> > > >> >> >> On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa > >> >> > >> >> >> wrote: > >> >> >> > Hi all, > >> >> >> > I am not sure if this is the rigth place to ask! > >> >> >> > > >> >> >> > I created a small console to execute python command by using > >> >> Qscintilla > >> >> >> > python bindings but something doesnt work with MIME data. > >> >> >> > > >> >> >> > My code is: > >> >> >> > > >> >> >> > def fromMimeData(self, source): > >> >> >> > if source.hasText(): > >> >> >> > pasteList = QStringList() > >> >> >> > pasteList = source.text().split("\n") > >> >> >> > if (len(pasteList) > 1): > >> >> >> > self.move_cursor_to_end() > >> >> >> > for line in pasteList[:-1]: > >> >> >> > self.append(line) > >> >> >> > self.move_cursor_to_end() > >> >> >> > self.runCommand(unicode(self.currentCommand())) > >> >> >> > self.append(unicode(pasteList[-1])) > >> >> >> > self.move_cursor_to_end() > >> >> >> > > >> >> >> > First question: when I paste some text in console and run > command > >> I > >> >> >> > get: > >> >> >> > > >> >> >> > TypeError: invalid result type from PythonEdit.fromMimeData() > >> >> >> > > >> >> >> > How I can avoid it? > >> >> >> > >> >> >> fromMimeData() should return a 2-tuple of the text as a > QByteArray > >> and > >> >> a > >> >> >> bool set if the selection is rectangular. > >> >> >> > >> >> > > >> >> > Thanks for your reply. > >> >> > > >> >> > oddly the paste command works well although returns that error! > >> >> > how should I manage the contents of tuple? > >> >> > >> >> I don't know what your code is supposed to do. If your > implementation > >> of > >> >> fromMimeData() is adding extra behaviour (rather than changing the > >> >> default > >> >> behaviour) then call the super-class implementation, ie. add the > >> >> following > >> >> at the end... > >> >> > >> >> return super(MyClass, self).fromMimeData(source) > >> >> > >> >> > >> > That solve the problem about typeError, but now it paste twice the > same > >> > word! > >> > You can see the source code here [1] (MIME data stuff is at line > 418). > >> > >> The purpose of fromMimeData() is to allow you to specify how MIME data > is > >> converted to text. It looks like you are trying to use it for another > >> purpose. You should probably look at reimplementing dropEvent() > instead. > >> > >> > > I thought it would work like insertFromMimeData [1]. > > I tested it with QTextEdit widget and works fine! > > > > I need that to execute multi-line command in my shell i.e.: > >>>> if True: > > . . .print "Hello" > > . . . if False: > > . . .print "Bye Bye" > > > > so the last command line only paste the text doesnt run it! > > > > Also, I implemented dropEvent() and has worked only for drag and drop > event > > and not to paste :-( > > So reimplement paste(). > > As you can see from the video [1] operations paste and drop works fine. However, with this configuration [2] I can not paste or drop a piece of text to a specific position of the cursor is the clipboard and mimedata are inserted at the end of the line! You can also see this problem in the video! Thanks for your time!! Anyway, if you can not replicate it, apparently it's just my problem! I can send you the source code (a simple widget) so that you can replicate it! Regards, -SL [1] - http://lrssvt.ns0.it/pasteDropMimeData.ogv [2] - https://gist.github.com/3755609 > Phil > -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi, 2012/9/19 Phil Thompson > On Wed, 19 Sep 2012 14:54:57 +0200, Salvatore Larosa > wrote: > > Hi Phil, > > > > 2012/9/19 Phil Thompson > > > >> On Wed, 19 Sep 2012 08:05:42 +0200, Salvatore Larosa > > >> wrote: > >> > Hi, > >> > > >> > 2012/9/19 Phil Thompson > >> > > >> >> On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa > >> > >> >> wrote: > >> >> > Hi all, > >> >> > I am not sure if this is the rigth place to ask! > >> >> > > >> >> > I created a small console to execute python command by using > >> Qscintilla > >> >> > python bindings but something doesnt work with MIME data. > >> >> > > >> >> > My code is: > >> >> > > >> >> > def fromMimeData(self, source): > >> >> > if source.hasText(): > >> >> > pasteList = QStringList() > >> >> > pasteList = source.text().split("\n") > >> >> > if (len(pasteList) > 1): > >> >> > self.move_cursor_to_end() > >> >> > for line in pasteList[:-1]: > >> >> > self.append(line) > >> >> > self.move_cursor_to_end() > >> >> > self.runCommand(unicode(self.currentCommand())) > >> >> > self.append(unicode(pasteList[-1])) > >> >> > self.move_cursor_to_end() > >> >> > > >> >> > First question: when I paste some text in console and run command > I > >> >> > get: > >> >> > > >> >> > TypeError: invalid result type from PythonEdit.fromMimeData() > >> >> > > >> >> > How I can avoid it? > >> >> > >> >> fromMimeData() should return a 2-tuple of the text as a QByteArray > and > >> a > >> >> bool set if the selection is rectangular. > >> >> > >> > > >> > Thanks for your reply. > >> > > >> > oddly the paste command works well although returns that error! > >> > how should I manage the contents of tuple? > >> > >> I don't know what your code is supposed to do. If your implementation > of > >> fromMimeData() is adding extra behaviour (rather than changing the > >> default > >> behaviour) then call the super-class implementation, ie. add the > >> following > >> at the end... > >> > >> return super(MyClass, self).fromMimeData(source) > >> > >> > > That solve the problem about typeError, but now it paste twice the same > > word! > > You can see the source code here [1] (MIME data stuff is at line 418). > > The purpose of fromMimeData() is to allow you to specify how MIME data is > converted to text. It looks like you are trying to use it for another > purpose. You should probably look at reimplementing dropEvent() instead. > > I thought it would work like insertFromMimeData [1]. I tested it with QTextEdit widget and works fine! I need that to execute multi-line command in my shell i.e.: >>> if True: . . .print "Hello" . . . if False: . . .print "Bye Bye" so the last command line only paste the text doesnt run it! Also, I implemented dropEvent() and has worked only for drag and drop event and not to paste :-( Anyway, thanks a lot! Regards -SL [1] - http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtextedit.html#insertFromMimeData > Phil > -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi Phil, 2012/9/19 Phil Thompson > On Wed, 19 Sep 2012 08:05:42 +0200, Salvatore Larosa > wrote: > > Hi, > > > > 2012/9/19 Phil Thompson > > > >> On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa > > >> wrote: > >> > Hi all, > >> > I am not sure if this is the rigth place to ask! > >> > > >> > I created a small console to execute python command by using > Qscintilla > >> > python bindings but something doesnt work with MIME data. > >> > > >> > My code is: > >> > > >> > def fromMimeData(self, source): > >> > if source.hasText(): > >> > pasteList = QStringList() > >> > pasteList = source.text().split("\n") > >> > if (len(pasteList) > 1): > >> > self.move_cursor_to_end() > >> > for line in pasteList[:-1]: > >> > self.append(line) > >> > self.move_cursor_to_end() > >> > self.runCommand(unicode(self.currentCommand())) > >> > self.append(unicode(pasteList[-1])) > >> > self.move_cursor_to_end() > >> > > >> > First question: when I paste some text in console and run command I > >> > get: > >> > > >> > TypeError: invalid result type from PythonEdit.fromMimeData() > >> > > >> > How I can avoid it? > >> > >> fromMimeData() should return a 2-tuple of the text as a QByteArray and > a > >> bool set if the selection is rectangular. > >> > > > > Thanks for your reply. > > > > oddly the paste command works well although returns that error! > > how should I manage the contents of tuple? > > I don't know what your code is supposed to do. If your implementation of > fromMimeData() is adding extra behaviour (rather than changing the default > behaviour) then call the super-class implementation, ie. add the following > at the end... > > return super(MyClass, self).fromMimeData(source) > > That solve the problem about typeError, but now it paste twice the same word! You can see the source code here [1] (MIME data stuff is at line 418). Thanks for your help! Regards, [1] - https://gist.github.com/3749286 > >> > Second question: If in my console I typed some text ( e.g def > >> > blablabla(self): ) and then > >> > I want edit it by replacing "self" with "source" by using paste > >> > command, > >> > the pasted text > >> > is placed at the end of the current line and not between brace > getting > >> the > >> > following result: > >> > > >> > def blablabla(self):source > >> > > >> > Any idea on how I can solve it? > >> > >> I can't reproduce that. What does move_cursor_to_end() do in the above > >> code? > >> > > > > move_cursor_to_end() move the cursor at the end of the current line!. > > the result doesnt change if I comment out it! > > if in my code I don't use the fromMimeData method, paste and drag/frop > > event does work as expected! > > But I need it to execute command when multi-line text is dropped or > pasted! > > > > > >> Phil > >> > > > > Regards, > > > > -SL > > Phil > -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi, 2012/9/19 Phil Thompson > On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa > wrote: > > Hi all, > > I am not sure if this is the rigth place to ask! > > > > I created a small console to execute python command by using Qscintilla > > python bindings but something doesnt work with MIME data. > > > > My code is: > > > > def fromMimeData(self, source): > > if source.hasText(): > > pasteList = QStringList() > > pasteList = source.text().split("\n") > > if (len(pasteList) > 1): > > self.move_cursor_to_end() > > for line in pasteList[:-1]: > > self.append(line) > > self.move_cursor_to_end() > > self.runCommand(unicode(self.currentCommand())) > > self.append(unicode(pasteList[-1])) > > self.move_cursor_to_end() > > > > First question: when I paste some text in console and run command I get: > > > > TypeError: invalid result type from PythonEdit.fromMimeData() > > > > How I can avoid it? > > fromMimeData() should return a 2-tuple of the text as a QByteArray and a > bool set if the selection is rectangular. > Thanks for your reply. oddly the paste command works well although returns that error! how should I manage the contents of tuple? > > > Second question: If in my console I typed some text ( e.g def > > blablabla(self): ) and then > > I want edit it by replacing "self" with "source" by using paste command, > > the pasted text > > is placed at the end of the current line and not between brace getting > the > > following result: > > > > def blablabla(self):source > > > > Any idea on how I can solve it? > > I can't reproduce that. What does move_cursor_to_end() do in the above > code? > move_cursor_to_end() move the cursor at the end of the current line!. the result doesnt change if I comment out it! if in my code I don't use the fromMimeData method, paste and drag/frop event does work as expected! But I need it to execute command when multi-line text is dropped or pasted! > Phil > Regards, -SL -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Weird behavior in fromMimeData method (pyScintilla)
Hi all, I am not sure if this is the rigth place to ask! I created a small console to execute python command by using Qscintilla python bindings but something doesnt work with MIME data. My code is: def fromMimeData(self, source): if source.hasText(): pasteList = QStringList() pasteList = source.text().split("\n") if (len(pasteList) > 1): self.move_cursor_to_end() for line in pasteList[:-1]: self.append(line) self.move_cursor_to_end() self.runCommand(unicode(self.currentCommand())) self.append(unicode(pasteList[-1])) self.move_cursor_to_end() First question: when I paste some text in console and run command I get: TypeError: invalid result type from PythonEdit.fromMimeData() How I can avoid it? Second question: If in my console I typed some text ( e.g def blablabla(self): ) and then I want edit it by replacing "self" with "source" by using paste command, the pasted text is placed at the end of the current line and not between brace getting the following result: def blablabla(self):source Any idea on how I can solve it? Regards, - SL -- Salvatore Larosa linkedIn: http://linkedin.com/in/larosasalvatore twitter: @lrssvt skype: s.larosa IRC: lrssvt on freenode ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt