[Myro-users] pickAColor and makeColor problems

Douglas S. Blank dblank at cs.brynmawr.edu
Fri Mar 27 11:31:06 EDT 2009


douglas at cems.uvm.edu wrote:
> I'm having trouble with pickAColor() and makeColor().
> It looks like there's extra stuff at the end of the return value from the
> function that is causing a problem(?). 
> 
>>>> from myro import *
> (c) 2006-2007 Institute for Personal Robots in Education
> [See http://www.roboteducation.org/ for more information]
> Myro version 2.8.2 is ready!
>>>> print makeColor(255,0,0)
> <Color instance (r=255, g=0, b=0)>)
>                                 ^^^??
> 
> Another example:
>>>> color = pickAColor()
>>>> print color
> <Color instance (r=255, g=0, b=0)>)

Jeanne,

Yes, looks like a typo in the representation. Shouldn't cause any 
problems, but we'll fix that.

> ..
> Whenever I don't get the error until I try to use the color 
> contextually (check the last line):
> 
>>>> shape.setFill(color)
> Exception in Tkinter callback
>>>> Traceback (most recent call last):
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
>     return self.func(*args)
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 456, in callit
>     func(*args)
>   File "C:\Python24\lib\site-packages\myro\graphics.py", line 207, in _tk_pump
>     result = command()
>   File "C:\Python24\lib\site-packages\myro\graphics.py", line 243, in func
>     return f(*args, **kw)
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 2176, in itemconfigure
>     return self._configure(('itemconfigure', tagOrId), cnf, kw)
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1130, in _configure
>     self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
> TclError: unknown color name "<Color instance (r=255, g=0, b=0)>)"

Yes, this is an artifact of using different representations of colors in 
two different ways. There is a representation of color for using in the 
pictures (the Color object you are using above), and a TK color 
representation for use with the shapes. For that you need to use the 
color string names (like "red", "yellow", etc). This is documented here:

http://wiki.roboteducation.org/Myro_Reference_Manual#Graphics_Objects_Interface

This is what we affectionately call a "talking point"... a obvious 
problem, but gives rise to talking about representations.

Hope that solves the problem.

-Doug

> Thanks for your help.
> Jeanne
> -------------------------------
> Jeanne Douglas, Senior Lecturer
> Computer Science Department
> College of Engineering and Mathematical Sciences
> 333 Votey Hall
> University of Vermont
> Burlington, VT 05405
> http://www.cs.uvm.edu/~douglas/
> 
> 
> 
> 
> _______________________________________________
> myro-users mailing list
> myro-users at myro.roboteducation.org
> http://myro.roboteducation.org/mailman/listinfo/myro-users
> 


-- 
Douglas S. Blank
Director, Institute for Personal Robots in Education (IPRE)
http://www.roboteducation.org
Chair, and Associate Professor, Computer Science, Bryn Mawr College
http://cs.brynmawr.edu/~dblank  (610)526-6501


More information about the myro-users mailing list