Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turtle with compound shape doesn't get clicks #60632

Open
pythonick mannequin opened this issue Nov 7, 2012 · 5 comments
Open

turtle with compound shape doesn't get clicks #60632

pythonick mannequin opened this issue Nov 7, 2012 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@pythonick
Copy link
Mannequin

pythonick mannequin commented Nov 7, 2012

BPO 16428
Nosy @willingc
Files
  • issue_16428.patch
  • issue_16428.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2012-11-07.14:46:49.175>
    labels = ['type-bug', 'library']
    title = "turtle with compound shape doesn't get clicks"
    updated_at = <Date 2018-06-16.15:12:16.056>
    user = 'https://bugs.python.org/pythonick'

    bugs.python.org fields:

    activity = <Date 2018-06-16.15:12:16.056>
    actor = 'willingc'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2012-11-07.14:46:49.175>
    creator = 'pythonick'
    dependencies = []
    files = ['35463', '35585']
    hgrepos = []
    issue_num = 16428
    keywords = ['patch', 'needs review']
    message_count = 5.0
    messages = ['175106', '218970', '219658', '220326', '319747']
    nosy_count = 5.0
    nosy_names = ['gregorlingl', 'jesstess', 'pythonick', 'ingrid', 'willingc']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16428'
    versions = ['Python 3.6']

    @pythonick
    Copy link
    Mannequin Author

    pythonick mannequin commented Nov 7, 2012

    In the standard turtle module, when a turtle has a custom shape of type "compound", it doesn't to respond to click events. No problem with polygon shapes.

    Observed on Windows XP, python 3.2.3, turtle version 1.1b, and on Linux, python 2.7.

    Test code:

    ##################################################
    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)
    def click(x,y): print("click at",x,y)
    t1.onclick(click)
    t2.onclick(click)
    turtle.mainloop()
    ##################################################

    When you click on the black square (i.e. t1), the message "click at..." is printed. When you click on the red square (i.e. t2), nothing happens.

    @pythonick pythonick mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 7, 2012
    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented May 23, 2014

    I tried the same script in Python 2.7 and Python 3.4.1 on OSX and had the same results.

    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Jun 3, 2014

    Looks like the issue is that when you are registering mouse events through turtle, it uses Shape._item. For polygon shapes, that's the actual shape item, but for compound shapes, it is an array of shape items. I have attached a patch that makes it so when there is a compound shape, it will iterate over the _item array and add the listener to each individual shape.

    @ingrid
    Copy link
    Mannequin

    ingrid mannequin commented Jun 12, 2014

    I updated the patch to use the gui check in Lib/test/support, and I renamed the test file to be test_turtle_guionly.

    @willingc
    Copy link
    Contributor

    This issue is "new contributor"-friendly.

    The next steps would be to apply the patch to a recent version of Python 3, check if tests run cleanly, and if the patch resolves the issue.

    I'm sorry ingrid that the patch review languished on the issue tracker.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    1 participant