title: Python turtle ondrag event vs. compound shapes
body: <p>When I register a polygon, or a compound shape with only a single component, I'm able to create a turtle cursor using that shape, add a drag event handler, and drag it around the screen.</p>
  
  <p>But when I register a compound shape with a second component, I can no longer drag it:</p>
  
  <pre><code>from turtle import Turtle, Screen, Shape
  
  def simple_polygon(turtle):
  
      turtle.begin_poly()
      turtle.circle(50)
      turtle.end_poly()
      screen.register_shape("simple_polygon", turtle.get_poly())
  
      turtle.reset()
  
  def compound_single(turtle):
  
      shape = Shape("compound")
  
      turtle.begin_poly()
      turtle.circle(50)
      turtle.end_poly()
      shape.addcomponent(turtle.get_poly(), "blue", "blue")  # component #1
      screen.register_shape("compound_single", shape)
  
      turtle.reset()
  
  def compound_double(turtle):
  
      shape = Shape("compound")
  
      turtle.begin_poly()
      turtle.circle(50)
      turtle.end_poly()
      shape.addcomponent(turtle.get_poly(), "green", "green")  # component #1
  
      turtle.penup()
      turtle.left(90)
      turtle.forward(25)
      turtle.right(90)
      turtle.pendown()
  
      turtle.begin_poly()
      turtle.circle(25)
      turtle.end_poly()
      shape.addcomponent(turtle.get_poly(), "yellow", "yellow")  # component #2
      screen.register_shape("compound_double", shape)
  
      turtle.reset()
  
  def drag_handler(turtle, x, y):
      turtle.ondrag(None)  # disable ondrag event inside drag_handler
      turtle.goto(x, y)
      turtle.ondrag(lambda x, y, turtle=turtle: drag_handler(turtle, x, y))
  
  screen = Screen()
  
  magic_marker = Turtle()
  simple_polygon(magic_marker)
  compound_single(magic_marker)
  compound_double(magic_marker)
  magic_marker.hideturtle()
  
  red = Turtle(shape="simple_polygon")
  red.color("red")
  red.penup()
  red.goto(150, 150)
  red.ondrag(lambda x, y: drag_handler(red, x, y))
  
  blue = Turtle(shape="compound_single")
  blue.penup()
  blue.goto(-150, -150)
  blue.ondrag(lambda x, y: drag_handler(blue, x, y))
  
  mostly_green = Turtle(shape="compound_double")
  mostly_green.penup()
  mostly_green.goto(150, -150)
  mostly_green.ondrag(lambda x, y: drag_handler(mostly_green, x, y))
  
  screen.mainloop()
  </code></pre>
  
  <p>You'll find that only two of the three shapes generated can be dragged.  Comment out this line:</p>
  
  <pre><code>shape.addcomponent(turtle.get_poly(), "yellow", "yellow")  # component #2
  </code></pre>
  
  <p>and the third circle will be all green and become draggable.</p>
  
  <p>I can't find any mention in the turtle documentation about compound shapes with mutiple components not being valid cursors as far as dragging.  It doesn't make any difference whether the second component is completely within, overlapping or outside the first.</p>
  
  <p>Looking at the turtle code, I see no distinction, leading me to believe that this problem is in the tkinter underpinning and not documented properly in turtle.  Is this problem Unix or OSX specific?</p>
  
  <p>Am I missing something?  Why can't I drag cursors built out of multiple components?</p>
  
  <p><a href="https://i.stack.imgur.com/f0loX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f0loX.png" alt="enter image description here"></a></p>