Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32840 > unrolled thread
| Started by | python@graner.name |
|---|---|
| First post | 2012-11-06 22:13 +0100 |
| Last post | 2012-11-06 23:20 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
clicking on turtle python@graner.name - 2012-11-06 22:13 +0100
Re: clicking on turtle Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-06 23:20 +0000
| From | python@graner.name |
|---|---|
| Date | 2012-11-06 22:13 +0100 |
| Subject | clicking on turtle |
| Message-ID | <mailman.3337.1352236403.27098.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-11-06 23:20 +0000 |
| Message-ID | <50999b39$0$29980$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #32840 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web