clicking on turtle

Discussion in 'Python' started by python@graner.name, Nov 6, 2012.

  1. Guest

    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
     
    , Nov 6, 2012
    #1
    1. Advertisements

  2. 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
     
    Steven D'Aprano, Nov 6, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adrian M. Hanslik

    Zooming/streching turtle

    Adrian M. Hanslik, Nov 28, 2004, in forum: Java
    Replies:
    2
    Views:
    449
    Paul van Rossem
    Nov 28, 2004
  2. jevitop
    Replies:
    2
    Views:
    6,195
    Stewart Gordon
    Sep 17, 2003
  3. Brent W. Hughes

    Python and Turtle Graphics

    Brent W. Hughes, Jul 19, 2004, in forum: Python
    Replies:
    4
    Views:
    1,730
    Lee Harr
    Jul 20, 2004
  4. Brent W. Hughes

    Slow turtle

    Brent W. Hughes, Jul 31, 2004, in forum: Python
    Replies:
    1
    Views:
    430
    Peter Otten
    Jul 31, 2004
  5. Dick Moores

    Saving output of Turtle Graphics?

    Dick Moores, Apr 7, 2007, in forum: Python
    Replies:
    7
    Views:
    643
    Dick Moores
    Apr 7, 2007
  6. tomy
    Replies:
    5
    Views:
    419
  7. Nicolas Graner

    clicking on turtle

    Nicolas Graner, Nov 6, 2012, in forum: Python
    Replies:
    0
    Views:
    302
    Nicolas Graner
    Nov 6, 2012
  8. Adam Funk
    Replies:
    7
    Views:
    425
    Adam Funk
    Feb 6, 2013
Loading...