Wow, this was quicker than I would have expected.
Here is a question: 
The button will appear automatically instead of the text when the body 
contains 10k+ lines (or 5k maybe), right?
This solution is great!

Also, please consider adding also this button:

b = QtGui.QPushButton('Copy body to clipboard')

def onClicked(checked=False,p=p.copy(),s=s):
    c.gui.replaceClipboardWith(p.b)

b.clicked.connect(onClicked)
layout.addWidget(b)






On Friday, August 29, 2014 3:57:39 AM UTC+2, Edward K. Ream wrote:
>
> On Thursday, August 28, 2014 12:07:36 PM UTC-5, Edward K. Ream wrote:
>>
>> On Thu, Aug 28, 2014 at 11:49 AM, Fidel N <[email protected] 
>> <javascript:>> wrote: 
>>
>> > Actually, just some short of "loading paused" button instead of a node 
>> body, 
>> > such as when you click it, the node body will load, would be enough. 
>>
>> Great idea.  Leo's body pane is a QTextBrowser, so "filling" the node 
>> with one or two buttons should be possible.  I'll prototype that 
>> "today"(tm). 
>>
>
> Well, "today" actually came today.
>
> Here is a *prototype* that you can run from any Leo node.  Please, as an 
> extra precaution, save your leo file before running this ;-)  And then, 
> when in doubt, do *not* save the file after running the script.  Clear?
>
> Running the script will hide the edit widget and show a "Load Text" 
> button.  Click the button to restore things as they were.
>
> Important: the button will remain until you click it, even if you change 
> nodes.  But if you do change nodes, you will see the correct text for the 
> new node under the button.
>
> Regardless of the current node, clicking the button will take you back to 
> the original node, and will restore the proper text there.  But don't try 
> deleting the original node.  Hehe.  There are limits to the prototype!
>
> ----- start ----
> from leo.core.leoQt import QtGui
> edit = c.frame.body.widget.widget # A LeoQTextBrowser.
> frame = edit.parent() # A QWidget
> layout = frame.layout()
>
> # Clear the text without clearing p.b
> # The selecting lockout prevents setText from changing p.b.
> s = p.b
> c.frame.tree.selecting = True
> edit.setText('')
> c.frame.tree.selecting = False
> assert p.b == s
>
> b = QtGui.QPushButton('Load Text')
>
> def onClicked(checked=False,p=p.copy(),s=s):
>     c.selectPosition(p)
>     edit.setPlainText(s)
>     layout.addWidget(edit)
>     layout.removeWidget(b)
>     b.deleteLater()
>     c.recolor_now()
>
> b.clicked.connect(onClicked)
> layout.addWidget(b)
> layout.removeWidget(edit) # Put button in middle.
> ----- end -----
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to