From 6f45a93913c280d071da22a325d883d4efa98541 Mon Sep 17 00:00:00 2001 From: Quentin Rouland Date: Thu, 19 Jan 2017 15:14:44 +0100 Subject: [PATCH] Le retour de bobino --- MultiModal/multiModale.py | 4 ++-- Palette/palette.py | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/MultiModal/multiModale.py b/MultiModal/multiModale.py index d224ea0..85c4b62 100644 --- a/MultiModal/multiModale.py +++ b/MultiModal/multiModale.py @@ -1,6 +1,6 @@ from ivy.std_api import IvyBindMsg, IvySendMsg, IvyMainLoop -import myIvy +from LibCommon import myIvy from threading import Timer @@ -75,6 +75,6 @@ class MyIvyMultiModale(myIvy.MyIvy): IvyBindMsg(self.a.new_vocal_action, '^VOCAL action=(.*)') -MyIvyMultiModale("MultiModal", "172.31.190.255:2010") +MyIvyMultiModale("MultiModal", "127.255.255.255:2010") IvyMainLoop() \ No newline at end of file diff --git a/Palette/palette.py b/Palette/palette.py index bfa5a1b..4d7e2a6 100644 --- a/Palette/palette.py +++ b/Palette/palette.py @@ -1,5 +1,5 @@ import turtle -import myIvy +from LibCommon import myIvy from ivy.std_api import * LIST_FORM = [] @@ -36,15 +36,17 @@ class Rectangle(Form): class MyTurtle(turtle.Turtle): - def __init__(self, color="green"): + def __init__(self, color="green", bgcolor="#FFFFFF"): turtle.Turtle.__init__(self, shape="turtle") + self.bgcolor = bgcolor + self.pensize(3) self.my_turtle_color = color self.color(color) self.screen = turtle.Screen() - self.screen.bgcolor("#FFFFFF") + self.screen.bgcolor(bgcolor) self.screen.title("Palette") self.screen.setup(1000, 600, 1, -1) self.screen.setworldcoordinates(0, 600, 1000, 0) @@ -84,11 +86,11 @@ class MyTurtle(turtle.Turtle): self.__end_draw() def delete_rectangle(self, rectangle): - self.__setup_draw(rectangle.x, rectangle.y, color="#FFFFFF") + self.__setup_draw(rectangle.x, rectangle.y, color=self.bgcolor) - def onclick(self, x, y): + def onclick(self, x, y, **kwargs): myturtle.goto(x, y) - IvySendMsg("PALETTE x={} y={}".format(x,y)) + IvySendMsg("PALETTE x={} y={}".format(x, y)) class MyIvyPalette(myIvy.MyIvy): @@ -96,10 +98,13 @@ class MyIvyPalette(myIvy.MyIvy): IvyBindMsg(self.create, '^MULTIMODAL forme=(.*) x=(.*) y=(.*) couleur=(.*)') def create(self, agent, *larg): - print('create [%s]', larg) if larg[0] == "RECTANGLE": - LIST_FORM.append(Rectangle(larg[1], larg[2], 200, 100, larg[3])) + r = Rectangle(larg[1], larg[2], 200, 100, larg[3]) + myturtle.draw_rectangle(r) + LIST_FORM.append(r) elif larg[0] == "ROND": + c = Circle(larg[1], larg[2], 50, larg[3]) + myturtle.draw_circle(c) LIST_FORM.append(Circle(larg[1], larg[2], larg[3])) @@ -116,6 +121,6 @@ myturtle.draw_rectangle(Rectangle(300, 300, 100, 200, color="blue")) myturtle.setposition(500, 450) myturtle.draw_circle_here() -my_ivy = MyIvyPalette("Palette", "172.31.190.255:2010") +my_ivy = MyIvyPalette("Palette", "127.255.255.255:2010") myturtle.screen._root.mainloop()