Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > clicking on turtle

Reply
Thread Tools

clicking on turtle

 
 
python@graner.name
Guest
Posts: n/a
 
      11-06-2012
I have a problem with the standard "turtle" module. When a turtle has
a custom shape of type "compound", it doesn't seem to respond to click
events. No problem with polygon shapes.

Running python 3.2.3, turtle version 1.1b on Windows XP.

Here is my test file:

##################################################
import turtle
square = ((0,0),(0,20),(20,20),(20,0))
turtle.addshape("sq1", square) # sq1 = polygon shape
s = turtle.Shape("compound")
s.addcomponent(square, "red")
turtle.addshape("sq2", s) # sq2 = compound shape
t1 = turtle.Turtle(shape="sq1")
t2 = turtle.Turtle(shape="sq2")
t2.fd(20) # set the turtles side by side
def click(x,y): print("click at",x,y)
t1.onclick(click)
t2.onclick(click)
turtle.mainloop()
##################################################

When I run this and click on the black square (i.e. t1), the message
"click at..." gets printed on the console. When I click on the red
square (i.e. t2), nothing happens.

Bug or feature?

--Nicolas
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      11-06-2012
On Tue, 06 Nov 2012 22:13:21 +0100, python wrote:

> I have a problem with the standard "turtle" module. When a turtle has a
> custom shape of type "compound", it doesn't seem to respond to click
> events. No problem with polygon shapes.

[...]
> When I run this and click on the black square (i.e. t1), the message
> "click at..." gets printed on the console. When I click on the red
> square (i.e. t2), nothing happens.


I don't know enough about turtle graphics to tell whether it's a bug in
your code, or a bug in the turtle, but I can confirm that the same
behaviour occurs in Python 2.7 on Linux.


--
Steven

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting a click on the turtle screen when the turtle isn't doinganything? Adam Funk Python 7 02-06-2013 09:52 PM
Re: clicking on turtle Peter Otten Python 0 11-07-2012 12:54 PM
clicking on turtle Nicolas Graner Python 0 11-06-2012 09:09 PM
Zooming/streching turtle Adrian M. Hanslik Java 2 11-28-2004 08:16 PM
I want to be able to access the internet by opening my browser and not right clicking and then clicking connect. James Johnson Computer Support 1 05-15-2004 03:40 AM



Advertisments