In an internet search I found that saving would probably best be done by 
walking through all the blocks on a page, of which the image would be one.  
During restoring a body, I suppose that one would insert the blocks one by 
one, though I am less clear about how to do that.  It seems to me that if 
an image were stored as a data: url, the image bytes could be stored as 
text in a UA, so everything could be included in the Leo outline.

So it may be feasible!

I have attached a small package with my demo experiment.  Unzip the zip 
file, open the Leo outline, and run its external file in a console.  Click 
in the Qt window that opens - nothing will seem to happen but it will 
locate the cursor in the frame.  Then click the pushbutton.  The image will 
get inserted at that point.  You can do this more than once to insert at 
different places.  When the image is inserted, the program will print the 
contents of the widget to the console.  You will notice a weird character - 
that is the special unicode character that can contain the image data.

The program requires PyQt6, but you could edit to use PyQt5 if that's what 
you have installed.

On Wednesday, March 29, 2023 at 10:24:33 AM UTC-4 Edward K. Ream wrote:

> On Tue, Mar 28, 2023 at 5:04 PM Thomas Passin <tbp1...@gmail.com> wrote:
>
> It would be very useful if an image could be embedded into a Leo body.  
>> Probably no one would want to do this in a program or script, but for 
>> documentation it could be very helpful.
>>
> ... 
>
>> In theory it should be possible to put an image into a Leo node.  Qt has 
>> a way to do it, and I have written a little test Qt program that can put 
>> one into a QTextBrowser or a QTextEdit widget at the cursor location.
>>
>> The way Qt does it is to insert a special Unicode character:
>>
>
> I played around with this a year (or 5?) ago. I kinda worked, but I seem 
> to remember there were problems. Probably something to do with reloading 
> the images when reloading Leo or re-visiting nodes.  Naively I would think 
> those problems could be solved just by searching for the special character. 
> I have no idea why I gave up.
>
> In short, I think this would be a great addition to Leo. Let's give it a 
> go.
>
> 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/7fec9ae2-12d2-41bc-96f7-b7b5c67569can%40googlegroups.com.

<<attachment: insert-image.zip>>

Reply via email to