Bug or feature (or just not jet implemented) in canvas copy
in OpenSesame
Hi,
Having a sketchpad with a line (names "B") and an arrow (named "A") I would expect naively that the following code:
from openexp.mouse import mouse my_mouse = mouse(exp) my_canvas = self.copy_sketchpad("welcome") my_Arrow = my_canvas['A'] my_Line = my_canvas['B'] while True: pos, time = my_mouse.get_pos() my_Arrow.ex = pos[0] my_Arrow.ey = pos[1] my_Line.ex = pos[0] my_Line.ey = pos[1] my_canvas.show()
Would let both arrow and line endings to follow my mouse pointer. But:
With the "Psycho" and "Xpyriment" back-ends, only the line-ending follows,The arrow stays unchanged
With the "legacy" back-end, I get the following error:
File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libopensesame\inline_script.py", line 116, in run self.workspace._exec(self.crun) File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libopensesame\base_python_workspace.py", line 124, in _exec exec(bytecode, self._globals) Inline script, line 4, in <module> File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\libopensesame\inline_script.py", line 183, in copy_sketchpad c.copy(self.experiment.items[sketchpad_name].canvas) File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\legacy.py", line 158, in copy Canvas.copy(self, canvas) File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\canvas.py", line 784, in copy for name, element in canvas._elements.items() File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\canvas.py", line 784, in <listcomp> for name, element in canvas._elements.items() File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\_element\legacy.py", line 47, in copy return self.__class__(canvas, **properties) TypeError: __init__() missing 4 required positional arguments: 'sx', 'sy', 'ex', and 'ey'
So apparently the copy function chokes.
When removing the arrow, the legacy back-end does allow me to copy the canvas.
I am trying to create a plugin, and there I seem to be unable to use copy_sketchpad. There I use Canvas.copy on the canvas element of the sketchpad item, and see the same behavior.
Regards,
Mark
Comments
Hi Mark,
Thanks for this. I filed an issue, and it should be fixed for 3.3.1.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
And there is also the issue of the arrows not reacting to the position properties changing...