Post Reply 
Python: TEXTOUT_P, CHOOSE, INPUT here is how it works 22.jan addded a TextOut functio
01-23-2022, 11:16 PM
Post: #4
RE: Python: TEXTOUT_P, CHOOSE, INPUT here is how it works Correction 17.Jan 2022
I've just published a new Version of my Mandelbrot Explorer.
included is a handy routine for use of HOME TEXTOUT_P. Here is the code snipped
Code:

from hpprime import *

def string(arg):                #create a string understood by HOME environment
    return '"' + str(arg) +'"'
    
def RGB(r,g,b):                 #make RGB understood by HOME environment
    return (r*256+g)*256+b
    
def strip(arg):                 #strip parantheses from a tuple converted to string
    return str(arg)[1:-1]

def TxtOut(t,x,y,f,c,*args):    #provide an easy to handle interface to TEXTOUT_P in HOME
    if len(args)>2:             #Syntax: TxtOut(string,x,y,font,color[,max_width[,background color]]
       raise(SyntaxError("too many arguments"))
    if True in [isinstance(i,list) for i in t]:
       raise(TypeError("can't convert 'list' object to str implicitly"))
    parms=(int(x),int(y),int(f),int(c))
    if len(args)>0:parms+=(int(args[0]),) #add max_width
    if len(args)>1:parms+=(int(args[1]),) #add background color
    return eval('TEXTOUT_P('+string(t)+','+strip(parms)+')')
Perhaps it is of use for someone

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


Messages In This Thread
RE: Python: TEXTOUT_P, CHOOSE, INPUT here is how it works Correction 17.Jan 2022 - Guenter Schink - 01-23-2022 11:16 PM



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