acircle.getCenter() to (x,y) coordinates in Python

Irv Kalb Irv at furrypants.com
Sun Dec 24 00:08:55 EST 2017


> On Dec 23, 2017, at 11:44 AM, G Yu <neptinizer101 at gmail.com> wrote:
> 
> My program has two circles: one stationary circle, drawn at a random location; and one moving circle, consistently drawn in the same place in the graphics window.
> 
> <snip>
> 
> Currently, acircle.getCenter() outputs this:
> 
> <graphics.Point object at 0x0000013E0D263668>
> <graphics.Point object at 0x0000013E0D263B00>
> 
> I don't understand/can't use the format that the locations are printed in.
> 
> How do I convert the above format to "usable" Cartesian coordinates?  Or is there a simpler way to solve this problem?
> 
> Thanks!
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

I found this document that looks like it described the "graphics" module that you are using (it does describe the getCenter call that you showed):

  http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf <http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf>

If this is the module, then Points are objects, and what you are seeing is the memory address of those points.  Section 3.1 of the document describes how you can call the getX() and getY() methods on any point to get the x and y values:
getX() Returns the x coordinate of a point. Example: xValue = aPoint.getX()

getY() Returns the y coordinate of a point. Example: yValue = aPoint.getY() 

Therefore, it sounds like you need to take the Point object that you have, and call the getX method and alto the getY method to get the coordinates you want.

Hope that helps,

Irv


More information about the Python-list mailing list