<div class="gmail_quote">Hi, <br><br>2012/9/19 Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, 18 Sep 2012 23:16:00 +0200, Salvatore Larosa <<a href="mailto:lrssvtml@gmail.com">lrssvtml@gmail.com</a>><br>
wrote:<br>
<div class="im">> Hi all,<br>
> I am not sure if this is the rigth place to ask!<br>
><br>
> I created a small console to execute python command by using Qscintilla<br>
> python bindings but something doesnt work with MIME data.<br>
><br>
> My code is:<br>
><br>
> def fromMimeData(self, source):<br>
> if source.hasText():<br>
> pasteList = QStringList()<br>
> pasteList = source.text().split("\n")<br>
> if (len(pasteList) > 1):<br>
> self.move_cursor_to_end()<br>
> for line in pasteList[:-1]:<br>
> self.append(line)<br>
> self.move_cursor_to_end()<br>
> self.runCommand(unicode(self.currentCommand()))<br>
> self.append(unicode(pasteList[-1]))<br>
> self.move_cursor_to_end()<br>
><br>
> First question: when I paste some text in console and run command I get:<br>
><br>
> TypeError: invalid result type from PythonEdit.fromMimeData()<br>
><br>
> How I can avoid it?<br>
<br>
</div>fromMimeData() should return a 2-tuple of the text as a QByteArray and a<br>
bool set if the selection is rectangular.<br></blockquote><div><br>Thanks for your reply.<br><br>oddly <span id="result_box" class="" lang="en"><span class="hps">the</span> <span class="hps">paste command</span> <span class="hps">works well</span> <span class="hps">although</span> <span class="hps">returns</span> <span class="hps">that error</span></span>!<br>
<span id="result_box" class="" lang="en"><span class="hps">how should I</span> <span class="hps">manage the contents of</span> <span class="hps"></span><span class="hps">tuple</span><span class="">?</span></span><br> </div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> Second question: If in my console I typed some text ( e.g def<br>
> blablabla(self): ) and then<br>
> I want edit it by replacing "self" with "source" by using paste command,<br>
> the pasted text<br>
> is placed at the end of the current line and not between brace getting<br>
the<br>
> following result:<br>
><br>
> def blablabla(self):source<br>
><br>
> Any idea on how I can solve it?<br>
<br>
</div>I can't reproduce that. What does move_cursor_to_end() do in the above<br>
code?<br></blockquote><div><br>move_cursor_to_end() move the cursor at the end of the current line!.<br>the result doesnt change if I comment out it!<br>if in my code I don't use the fromMimeData method, paste and drag/frop event does work as expected! <br>
But I need it to execute command when multi-line text is dropped or pasted!<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Phil<br>
</font></span></blockquote></div><br>Regards,<br><br>-SL<br><br clear="all"><br>-- <br>Salvatore Larosa<br>linkedIn: <a href="http://linkedin.com/in/larosasalvatore" target="_blank">http://linkedin.com/in/larosasalvatore</a><br>
twitter: @lrssvt<br>skype: s.larosa<br>IRC: lrssvt on freenode<br><br>