[PyQt] Weird behavior in fromMimeData method (pyScintilla)
Salvatore Larosa
lrssvtml at gmail.com
Wed Sep 19 07:05:42 BST 2012
Hi,
2012/9/19 Phil Thompson <phil at riverbankcomputing.com>
> On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa <lrssvtml at gmail.com>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120919/4f5fc0a3/attachment.html>
More information about the PyQt
mailing list