Ejemplo n.º 1
0
def drawpoint(args):
    if len(args)<4 or len(args) > 6:
        raise ArgumentError()
    argnum = len(args)
    c1 = int(NI.to_ascii(args[2]))
    c2 = int(NI.to_ascii(args[3]))
    width = int(NI.to_ascii(args[4])) if argnum>4 else None
    outline = to_col[args[5]] if argnum>5 else None
    root,canvas = args[0]
    canvas.create_rectangle(c1,c2,c1,c2,width=width,outline=outline)
    root.update()
    return
Ejemplo n.º 2
0
def drawtext(args):
    if len(args)<5 or len(args) > 7:
        raise ArgumentError()
    argnum = len(args)
    c1 = int(NI.to_ascii(args[2]))
    c2 = int(NI.to_ascii(args[3]))
    text = args[4].encode("UTF8")
    size = int(NI.to_ascii(args[5])) if argnum>5 else None
    color = to_col[args[6]] if argnum>6 else None
    font = "a " + str(size) if size is not None else "0 "
    root,canvas = args[0]
    canvas.create_text(c1,c2,text=text,font=font,fill=color,anchor="nw")
    root.update()
    return
Ejemplo n.º 3
0
def drawcircle(args):
    'requres canvas, 2 coords, radius compulsory; width, outline, fill optional'
    if len(args) < 5 or len(args) > 8:
        raise ArgumentError()
    argnum = len(args)
    root,canvas = args[0]
    x = int(NI.to_ascii(args[2]))
    y = int(NI.to_ascii(args[3]))
    r = int(NI.to_ascii(args[4]))
    width = int(NI.to_ascii(args[5])) if argnum>5 else None
    outline = to_col[args[6]] if argnum>6 else None
    fill = to_col[args[7]] if argnum>7 else None
    canvas.create_oval(x-r,y-r,x+r,y+r,width=width,fill=fill,outline=outline)
    canvas.update()
    return
Ejemplo n.º 4
0
def drawline(args):
    'requires the canvas, 4 coords compulsory and width and foreground color optional'
    if len(args) < 6 or len(args) > 8:
        raise ArgumentError()
    argnum = len(args)
    root,canvas = args[0]
    c1 = int(NI.to_ascii(args[2]))
    c2 = int(NI.to_ascii(args[3]))
    c3 = int(NI.to_ascii(args[4]))
    c4 = int(NI.to_ascii(args[5]))
    width = int(NI.to_ascii(args[6])) if argnum > 6 else None
    fill = to_col[args[7]] if argnum>7 else None
    canvas.create_line(c1,c2,c3,c4,width=width,fill=fill)
    canvas.update()
    return
Ejemplo n.º 5
0
def initgraphics(args,env):
    root = Tk()
    if len(args) < 3:
        raise ArgumentError()

    name = NI.interpret(args[0],env)
    name = name.encode('UTF8')
    height = int(NI.to_ascii(NI.interpret(args[1],env)))
    width = int(NI.to_ascii(NI.interpret(args[2],env)))
    root.title(name)
    root.configure(height=height, width=width)  #set width and height
    root.resizable(0,0)                         #disable resizing
    canvas = Canvas(root,width=width,height=height)
    canvas.pack(fill='both')

    #hide the windows
    root.withdraw()
    root.bind("<Key>",keyboardhandler)
    return root,canvas
Ejemplo n.º 6
0
def findString(args, env):
    if (len(args) < 2 or len(args) > 4):
        raise ArgumentError
    string = NI.interpret(args[0], env)
    pattern = NI.interpret(args[1], env)
    begin = (len(args)>2) and NI.interpret(args[2], env) or u'०'
    end =   (len(args)>3) and NI.interpret(args[3], env) or u'०'

    if type(string) != type(u'ल') \
       or type(u'ल') != type(pattern) \
       or type(u'ल') != type(pattern) \
        or type(u'ल') != type(pattern):
        raise ArgumentError

    begin = int(NI.to_ascii(begin))
    end = int(NI.to_ascii(end))
    
    if (end != 0):
        return NI.get_key_from_value(NI.map_num, string.find(pattern, begin, end))
    return NI.to_unicode(string.find(pattern, begin))
Ejemplo n.º 7
0
def squareRoot(args, env):
    if len(args) != 1:
        raise ArgumentError
    return NI.to_unicode(math.sqrt(NI.to_ascii(NI.interpret(args[0], env))))