Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Problem with the color setter of the Canvas element interface

Hi,

When I create a canvas object for a rectangle with the element interface, I couldn't change the color. I implemented the following:

my_canvas = Canvas()
# Element interface
my_canvas['my_rect'] = Rect(-10, -10, 20, 20, fill=True, color='red')
my_canvas.show()

clock.sleep(1000)

my_canvas['my_rect'].color = 'green'
my_canvas.show()

It complains with:

    my_canvas['my_rect'].color = 'green'
    ^^^^^^^^^^^^^^^
  File "D:\opensesame_4.0.5\Lib\site-packages\openexp\_canvas\_element\element.py", line 232, in _setter
    val = color(self.experiment, val)
          ^^^^^
NameError: name 'color' is not defined

Did I implement this correctly? By the way, color setting with the function interface works fine.

Best, Martin

Comments

Sign In or Register to comment.