Post Reply 
Python: How do I save a graphic?
10-07-2021, 10:25 PM
Post: #5
RE: Python: How do I save a graphic?
(10-07-2021 09:19 PM)Guenter Schink Wrote:  Thanks for your inputs, but that didn't help

Anyway a little bit of progress.

When I end the Mandelbrot Explorer, and I am in "Python Numeric View" and I enter

Code:
from hppprime import *
eval('AFiles("test.png"):=G1')

then G1 is successfully stored in test.png. But when I exchange quotes and double quotes a Syntax Error is raised. So far so good, that's an easy one.

Next try:
Code:
from hppprime import *
aa="test.png"
eval('AFiles(aa):=G1')

Results in Syntax Error

Next try:
Code:
from hppprime import *
aa="test.png"
xx=eval('AFiles(aa):=G1')

No Error, but also no file: test.png
type(xx) gives <class 'str'>, but print(xx) gives Error:Syntax Error of course as you can't print a class. I think.

Next try: Function in the Mandelbrot Explorer

Code:
def save():
    eval('AFiles("test3.png"):=G1')
    line(0,0,240,320,0,0) #to show the function was executed

Tataa test3.png is there

Next try:
Code:
def save():
    aa="test3.png"
    eval('AFiles(aa):=G1')          #prefacing with xx=  doesn't change anything
    line(0,0,240,320,0,0) #to show the function was executed
No error, but also no file,
Hmm ....

Conclusion so far: providing a file name directly works but submitting a file name as a variable does not.

any suggestions?
G√ľnter

Did you try eval('AFiles(' + aa + '):=G1')

Tom L
Cui bono?
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? - toml_12953 - 10-07-2021 10:25 PM



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