Post Reply 
Python oddities
05-05-2021, 08:56 PM
Post: #2
RE: Python oddities
(05-05-2021 07:41 PM)Guenter Schink Wrote:  reported to calcbeta

Beta 04/28 and earlier recent Betas
G2 and Virtual, not tested on G1

1. Reboot
2. Drawing not correct


1. Run a Python script from Home, change to any APP, and the G2 reboots.
From Tim's document "PPL-Changes + python.odt" I copied this snipped:

Code:
#PYTHON name
import sys
print(str(1+2)+sys.argv[0])
#end
Export ppl(a)
Begin
   PYTHON(name, a);
End;

The Python program runs o.k. from Home screen by entering ppl(5), but when I later push <APP> <Python> or any other App, the Prime kindly reports "Your HP Prime had a problem and will reboot in 3 seconds." Which it does. Short interrupt only, yet annoying. Every time I make some edits to a script I switch the Prime off and on again in order not to loose anything.

___________________________________________________________________________

2. Drawing functions in Python. Preface: I'm working my way to Python and your implementation of it as a newcomer. Maybe I overlook the obvious.

I've set up this short program to test some drawing functions. As you can see, I have used two options for setting the cartesian parameters. Either with "eval" of "hpprime" or with Python's "set_cartesian" (which is now deactivated) both work fine with "line_c" and "textout_c" but not with "fillrect_c" or "rect_c" that is the latter two don't do anything. The non-cartesian commands are there for comparison. These are the commands I have tested, can't say anything of the other ones.


Code:
#PYTHON name
from hpprime import *
eval("Xmin=-15.9")
eval("Xmax=15.9")
eval("Ymin=-11.9")
eval("Ymax=11.9")
#set_cartesian(-16,16,-11,11)
fillrect_c(0,0,0,30,30,0,0)
fillrect(0,0,0,320,240,0,0)
line_c(0, -15.9, 0, 15.9, 0, 0x00FF00)
line_c(0, 0, -10, 0, 10, 0xFF0000)
fillrect(0,110,80,100,80,0x00FFFF,0xFFFFFF)
textout(0,0,0,"PIXEL",0xffffff)
textout_c(0,-3,0,"CARTESIAN",0)
eval("wait()")
#end
Export zeich(a)
Begin
     PYTHON(name, a);
End;
3. I'm using the HOME environment because only there (true?) I can have various independent Python scripts. The <Symb> <Num> combination isn't really handy. But perhaps I haven't seen the obvious.

I ran all these tests again after I rest the Prime including formatting the "disk", no change.

Yet I think it's a great improvement and keeps me busy to explore new things, thank you very much for these achievements.

Günter

Where is PPL-Changes + python.odt?

When I try to export the program name (hat), I get an error at

Export hat()

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python oddities - Guenter Schink - 05-05-2021, 07:41 PM
RE: Python oddities - toml_12953 - 05-05-2021 08:56 PM
RE: Python oddities - Guenter Schink - 05-05-2021, 10:24 PM
RE: Python oddities - toml_12953 - 05-06-2021, 12:28 AM



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