Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-16 Thread Thomas Passin
Here is a revised version of my script to show the viewrendered3 plugin in 
the same pane as the body editor.  The command toggles between the VR3 
rendered view and the body editor view.  I have it connected to a button on 
the button bar.  You can use it without even enabling the plugin in your 
settings file.

@language python
"""Toggles the body frame between the body editor and
a Viewrendered3 rendered view.
"""
from leo.core.leoQt import QtWidgets
import leo.plugins.viewrendered3 as v3

def toggle_vr3_in_body(c):
flc = c.free_layout  # free layout controller
top = flc.get_top_splitter()
if top:
bfw = top.find_child(QtWidgets.QWidget, "bodyFrame")
kids = bfw.children()

qf0 = kids[0]
stacked_layout = qf0.children()[0]
h = c.hash()
if stacked_layout.count() == 1:
v3.controllers[h] = vr3 = v3.ViewRenderedController3(c)
stacked_layout.addWidget(vr3)

if stacked_layout.currentIndex() == 0:
# vr3 = v3.controllers[h]
# stacked_layout.setCurrentWidget(vr3)
vr3 = stacked_layout.widget(1)
stacked_layout.setCurrentIndex(1)
vr3.set_unfreeze()
else:
vr3 = stacked_layout.widget(1)
vr3.set_freeze()
stacked_layout.setCurrentIndex(0)

toggle_vr3_in_body(c)

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/5b8886b9-bd10-405c-8ef6-d22af41d648en%40googlegroups.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-14 Thread HaveF HaveF


Thomas, your private email on this topic was a Eureka moment for me. I 
realized that we Leo devs aren't aware of the hierarchy of Leo's Qt widgets.

Yes, we don't know...here is a nice version of the output 
.
 

I'll say more later.

 We are all looking forward to this :-D

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/8274ed6f-5e8d-4034-9149-29bdd9e1f4f4n%40googlegroups.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread jkn
Hey, that looks like great fun!


On Monday, May 13, 2024 at 3:00:58 PM UTC+1 Edward K. Ream wrote:

> On Sunday, May 12, 2024 at 4:17:19 PM UTC-5 tbp1...@gmail.com wrote:
>
> I have devised a script that can [swap the body and VR3 panes].  You can 
> put it into a button for easy activation, or you could make it into a 
> command in the Settings tree and bind it to a keystroke. 
>
>
> Thomas, your private email on this topic was a Eureka moment for me. I 
> realized that we Leo devs aren't aware of the hierarchy of Leo's Qt widgets.
>
> The following script helps cure that ignorance:
>
> """Scripts to discover Leo's Qt Widget hierarchy."""
> g.cls()
>
> total = 0
>
> def w_name(w):
> name = w.objectName() or 'no name'
> return f"<{name}>:{ w.__class__.__name__}"
>
> def dump(tag, w, level=0):
> global total
> total += 1
> ws = (level * 2) * ' '
> print(f"{id(w):<14} lvl {level:2}: {ws}{tag}:{w_name(w)}")
> 
> def dump_children(w, level=0):
> if 1:  # Specify wanted classes...
> wanted = (
> 'DynamicWindow', 'Frame', 'Layout',
> 'Splitter', 'Stacked', 'Text', 'Widget')
> children = [z for z in w.children()
> if any (z2 in z.__class__.__name__ for z2 in wanted)]
> else:  # Specifiy unwanted classes...
> ignore = ('action', 'animation', 'menu')
> children = [z for z in w.children()
> if not any (z2 in z.__class__.__name__.lower() for z2 in 
> ignore)]
> if children:
> for i, child in enumerate(children):
> dump(f"child {i}", child, level + 1)
> dump_children(child, level + 1)
> 
> def full_dump(tag, w, level=0):
> print('')
> print(f"Full dump of {w_name(w)} at {id(w)}...\n")
> dump(tag, w)
> dump_children(w)
> 
> if 1:
> full_dump('c.frame.top.parent()', c.frame.top.parent())
> else:
>
> flc = c.free_layout  # free layout controller
> top_splitter = flc.get_top_splitter()
> dump('c.frame.top.parent()', c.frame.top.parent())
> dump('c.frame.top', c.frame.top)
> full_dump('top_splitter', top_splitter)
>
> print('')
> print(f"total objects: {total}")
>
> And here is the output:
>
> Full dump of :QStackedWidget at 
> 2877793745520...
>
> 2877793745520  lvl  0: 
> c.frame.top.parent()::QStackedWidget
> 2877793745840  lvl  1:   child 0::QStackedLayout
> 2877687572080  lvl  1:   child 1::DynamicWindow
> 2877793745200  lvl  2: child 0:<_layout>:QLayout
> 2877687572560  lvl  2: child 1::QWidget
> 2877687572880  lvl  3:   child 0::QVBoxLayout
> 2877687573040  lvl  3:   child 1::NestedSplitter
> 2877793731920  lvl  4: child 0::NestedSplitter
> 2877692019248  lvl  5:   child 0::QFrame
> 2877692019408  lvl  6: child 0::QFrame
> 2877692019728  lvl  7:   child 
> 0::QStackedWidget
> 2877793746480  lvl  8: child 0::QStackedLayout
> 2877692019888  lvl  8: child 1::QWidget
> 2877692020368  lvl  9:   child 
> 0::LeoQTextBrowser
> 2877793746320  lvl 10: child 
> 0::QWidget
> 2877793746640  lvl 10: child 
> 1::QWidget
> 2877793550416  lvl 11:   child 0::QBoxLayout
> 2877793731440  lvl 10: child 
> 2::QWidget
> 2877793746800  lvl 11:   child 0::QBoxLayout
> 2877692020848  lvl  9:   child 1::QVBoxLayout
> 2877692021168  lvl  7:   child 1::QGridLayout
> 2877692021008  lvl  6: child 1::QGridLayout
> 2877793732080  lvl  5:   child 
> 1::NestedSplitterHandle
> 2877692019568  lvl  5:   child 
> 2::NestedSplitterHandle
> 2877687573200  lvl  4: child 1::NestedSplitter
> 2877687574640  lvl  5:   child 0::QFrame
> 2877687574800  lvl  6: child 0::QFrame
> 2877687575120  lvl  7:   child 0::QTabWidget
> 2877793746480  lvl  8: child 
> 0::QStackedWidget
> 2877793731440  lvl  9:   child 0::QStackedLayout
> 2877687575920  lvl  9:   child 1::QWidget
> 2877687576080  lvl 10: child 
> 0::QVBoxLayout
> 2877687576240  lvl 10: child 1::QFrame
> 2877687576400  lvl 11:   child 
> 0::QVBoxLayout
> 2877687576560  lvl 12: child 
> 0::QGridLayout
> 2877692018768  lvl 11:   child 
> 1::QListWidget
> 2877793746320  lvl 12: child 
> 0::QWidget
> 2877793746640  lvl 12: child 
> 1::QWidget
> 2877793743600  lvl 13:   child 0: name>:QBoxLayout
> 2877793746800  lvl 12: child 
> 2::QWidget
> 2877793743920  lvl 13:   child 0: name>:QBoxLayout
> 2877695206864  lvl  9:   child 
> 2::LeoQTextBrowser
> 2877793746800  lvl 10: child 
> 0::QWidget
> 2877793746640  lvl 

Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread Edward K. Ream
On Mon, May 13, 2024 at 9:38 AM Thomas wrote:

>> Thomas, your private email on this topic was a Eureka moment for me. I
realized that we Leo devs aren't aware of the hierarchy of Leo's Qt widgets.

> That's an understatement! - at least for me...  It explains why I had so
much trouble discovering when the body editor was created, by whom, and
what frame it is put into.  Your printout is stunningly complex.

Hehe. It took a lot of work to make the printout as simple as it is.

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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0-vq5e50imdni%2BNESaYscY_%2ByvXfrbn2co-8qs8xLc5Q%40mail.gmail.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread Thomas Passin

On Monday, May 13, 2024 at 10:00:58 AM UTC-4 Edward K. Ream wrote:

On Sunday, May 12, 2024 at 4:17:19 PM UTC-5 tbp1...@gmail.com wrote:

I have devised a script that can [swap the body and VR3 panes].  You can 
put it into a button for easy activation, or you could make it into a 
command in the Settings tree and bind it to a keystroke. 


Thomas, your private email on this topic was a Eureka moment for me. I 
realized that we Leo devs aren't aware of the hierarchy of Leo's Qt widgets.


That's a understatement! - at least for me...  It explains why I had so 
much trouble discovering when the body editor was created, by whom, and 
what frame it is put into.  Your printout is stunningly complex.
 

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/5646e000-c731-4959-8a56-15f62e63be1an%40googlegroups.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread Edward K. Ream
On Sunday, May 12, 2024 at 4:17:19 PM UTC-5 tbp1...@gmail.com wrote:

I have devised a script that can [swap the body and VR3 panes].  You can 
put it into a button for easy activation, or you could make it into a 
command in the Settings tree and bind it to a keystroke. 


Thomas, your private email on this topic was a Eureka moment for me. I 
realized that we Leo devs aren't aware of the hierarchy of Leo's Qt widgets.

The following script helps cure that ignorance:

"""Scripts to discover Leo's Qt Widget hierarchy."""
g.cls()

total = 0

def w_name(w):
name = w.objectName() or 'no name'
return f"<{name}>:{ w.__class__.__name__}"

def dump(tag, w, level=0):
global total
total += 1
ws = (level * 2) * ' '
print(f"{id(w):<14} lvl {level:2}: {ws}{tag}:{w_name(w)}")

def dump_children(w, level=0):
if 1:  # Specify wanted classes...
wanted = (
'DynamicWindow', 'Frame', 'Layout',
'Splitter', 'Stacked', 'Text', 'Widget')
children = [z for z in w.children()
if any (z2 in z.__class__.__name__ for z2 in wanted)]
else:  # Specifiy unwanted classes...
ignore = ('action', 'animation', 'menu')
children = [z for z in w.children()
if not any (z2 in z.__class__.__name__.lower() for z2 in 
ignore)]
if children:
for i, child in enumerate(children):
dump(f"child {i}", child, level + 1)
dump_children(child, level + 1)

def full_dump(tag, w, level=0):
print('')
print(f"Full dump of {w_name(w)} at {id(w)}...\n")
dump(tag, w)
dump_children(w)

if 1:
full_dump('c.frame.top.parent()', c.frame.top.parent())
else:
flc = c.free_layout  # free layout controller
top_splitter = flc.get_top_splitter()
dump('c.frame.top.parent()', c.frame.top.parent())
dump('c.frame.top', c.frame.top)
full_dump('top_splitter', top_splitter)

print('')
print(f"total objects: {total}")

And here is the output:

Full dump of :QStackedWidget at 2877793745520...

2877793745520  lvl  0: 
c.frame.top.parent()::QStackedWidget
2877793745840  lvl  1:   child 0::QStackedLayout
2877687572080  lvl  1:   child 1::DynamicWindow
2877793745200  lvl  2: child 0:<_layout>:QLayout
2877687572560  lvl  2: child 1::QWidget
2877687572880  lvl  3:   child 0::QVBoxLayout
2877687573040  lvl  3:   child 1::NestedSplitter
2877793731920  lvl  4: child 0::NestedSplitter
2877692019248  lvl  5:   child 0::QFrame
2877692019408  lvl  6: child 0::QFrame
2877692019728  lvl  7:   child 
0::QStackedWidget
2877793746480  lvl  8: child 0::QStackedLayout
2877692019888  lvl  8: child 1::QWidget
2877692020368  lvl  9:   child 
0::LeoQTextBrowser
2877793746320  lvl 10: child 
0::QWidget
2877793746640  lvl 10: child 
1::QWidget
2877793550416  lvl 11:   child 0::QBoxLayout
2877793731440  lvl 10: child 
2::QWidget
2877793746800  lvl 11:   child 0::QBoxLayout
2877692020848  lvl  9:   child 1::QVBoxLayout
2877692021168  lvl  7:   child 1::QGridLayout
2877692021008  lvl  6: child 1::QGridLayout
2877793732080  lvl  5:   child 
1::NestedSplitterHandle
2877692019568  lvl  5:   child 
2::NestedSplitterHandle
2877687573200  lvl  4: child 1::NestedSplitter
2877687574640  lvl  5:   child 0::QFrame
2877687574800  lvl  6: child 0::QFrame
2877687575120  lvl  7:   child 0::QTabWidget
2877793746480  lvl  8: child 
0::QStackedWidget
2877793731440  lvl  9:   child 0::QStackedLayout
2877687575920  lvl  9:   child 1::QWidget
2877687576080  lvl 10: child 
0::QVBoxLayout
2877687576240  lvl 10: child 1::QFrame
2877687576400  lvl 11:   child 
0::QVBoxLayout
2877687576560  lvl 12: child 
0::QGridLayout
2877692018768  lvl 11:   child 
1::QListWidget
2877793746320  lvl 12: child 
0::QWidget
2877793746640  lvl 12: child 
1::QWidget
2877793743600  lvl 13:   child 0::QBoxLayout
2877793746800  lvl 12: child 
2::QWidget
2877793743920  lvl 13:   child 0::QBoxLayout
2877695206864  lvl  9:   child 
2::LeoQTextBrowser
2877793746800  lvl 10: child 
0::QWidget
2877793746640  lvl 10: child 
1::QWidget
2877793746320  lvl 11:   child 0::QBoxLayout
2877793743920  lvl 10: child 
2::QWidget
2877793746320  lvl 11:   child 0::QBoxLayout
2877687575280  lvl  7:   child 1::QGridLayout
2877687575440  lvl  6: child 1::QGridLayout
2877687573360  

Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread Thomas Passin
Thank you, Lewis, much appreciated!

I'll be posting an improved version of the script later today. I've already 
added it as a vr3- command and button to my own MyLeoSettings.leo outline.

On Monday, May 13, 2024 at 3:31:23 AM UTC-4 lewis wrote:

> Thomas,
> Thanks for the script. I really appreciate the effort you have put into 
> improving the VR3 functionality.
>
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/266124b7-63d0-4bd6-8f9b-b0a44ed17bc2n%40googlegroups.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-13 Thread lewis
Thomas,
Thanks for the script. I really appreciate the effort you have put into 
improving the VR3 functionality.

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/52a6-7adf-449e-a8d5-e86760d97b9fn%40googlegroups.com.


Re: A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-12 Thread Thomas Passin
Attached is an example of rendering mixed text and graphics - in this case 
we are rendering a UML diagram using Asciidoc and PlantUML (PlantUML is 
basically a plugin for the external Asciidoctor).


On Sunday, May 12, 2024 at 5:17:19 PM UTC-4 Thomas Passin wrote:

Recently we have had discussions about how Trillum (and some other 
applications) can render graphics and text together.  Some of these 
applications have outlines and even clones similar to how Leo uses them.  A 
number of people have said that they wish that Leo could do the same.  
[...]
When this script has been used, the other ways of showing and hiding the 
VR3 pane don't work.  I will see if there is a way to work around this 
without needing to change VR3's code.  In the meantime, give the script 
below a try.  You can copy it to a new node in your Workbook and create a 
button for it.


It turns out that as long as you use one of the other ways to open VR3 
first, before using this new script, then the script doesn't interfere with 
them.

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/9a80c5ed-9f17-4fa6-9885-c51469300878n%40googlegroups.com.


A Script To Display The Viewrendered3 Pane in the Same Place s The Body

2024-05-12 Thread Thomas Passin
Recently we have had discussions about how Trillum (and some other 
applications) can render graphics and text together.  Some of these 
applications have outlines and even clones similar to how Leo uses them.  A 
number of people have said that they wish that Leo could do the same.  

Here are two of the discussion threads:
A Leo relative in the wild: Trilium Notes 

ENB: VR panes and the NestedSplitter plugin 


Typically one can edit in an editing view or display a fully rendered view 
that you don't edit directly.

In the discussion I pointed out that the Viewrendered3 plugin can take care 
of the mixed rendering tasks. You need to learn a bit of Markdown or 
RestructuredText (or Asciidoc) and then you can embed images, math 
formulas, and so on.  It would be possible to write scripts to simplify 
some of these details, but it's pretty easy as is.  With VR3 you have an 
additional pane for the VR3 display.  To make it more like Trillium, etc., 
and to save screen real estate, the VR3 display should display on top of 
the body pane.  You would swap it in or out depending on whether you want 
to edit or not.

I have devised a script that can do this swap.  You can put it into a 
button for easy activation, or you could make it into a command in the 
Settings tree and bind it to a keystroke.  With a tiny change to the script 
it will work for the Viewrendered plugin as well (but not in current *devel* 
versons).  
But VR has a more limited range for rendering that VR3.

When this script has been used, the other ways of showing and hiding the 
VR3 pane don't work.  I will see if there is a way to work around this 
without needing to change VR3's code.  In the meantime, give the script 
below a try.  You can copy it to a new node in your Workbook and create a 
button for it.

@language python
"""Toggles the body frame between the body editor and
a Viewrendered3 rendered view.
"""
from leo.core.leoQt import QtWidgets
import leo.plugins.viewrendered3 as v3

flc = c.free_layout  # free layout controller
top = flc.get_top_splitter()
if top:
bfw = top.find_child(QtWidgets.QWidget, "bodyFrame")
kids = bfw.children()

qf0 = kids[0]
stacked_layout = qf0.children()[0]

h = c.hash()
if stacked_layout.count() == 1:
v3.controllers[h] = vr3 = v3.ViewRenderedController3(c)
stacked_layout.addWidget(vr3)
vr3.show()
else:
vr3 = v3.controllers.get(h)

if stacked_layout.currentIndex() == 0:
stacked_layout.setCurrentWidget(vr3)
else:
stacked_layout.setCurrentIndex(0)


-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/e3f61ef9-7206-4420-8d43-b150cd557e91n%40googlegroups.com.