Post Reply 
Python: How do I save a graphic?
01-05-2023, 08:44 PM
Post: #9
RE: Python: How do I save a graphic?
Thank you for reviving this thread. I've resolved this problem quite a while ago, but omitted to report the solution here, apologies.

It's even easier than your proposal. Consider you deal with a graphic G1 in Python and wish to save it as "pic.png" using the variable "b", a simple two liner would do:
b="pic.png"
hpprime.eval('AFiles(" '+b+' "):=G1')


It's important to use the single and double quotes as shown.
The spaces I put between double and single quotes have to be deleted, I inserted them here just to show what's single and what's double quoting.

Single quotes around what needs to be passed as a command to the Home environment and double quotes what should be a string for the Home environment. The command above would show as AFiles("pic.png"):=G1 in the Home environment.

BTW the first three lines in your example can be replaced by the graphic commands within the hpprime module. Look there for dimgrob() and fillrect()

More about interfacing between Python and Home can be seen in my wonderful Smile Mandelbrot Explorer

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python: How do I save a graphic? - Guenter Schink - 01-05-2023 08:44 PM



User(s) browsing this thread: 1 Guest(s)