Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python Simple turtle graphic programme, what's wrong?

  1. Nov 19, 2016 #1
    I want to write a program when I click the turtle, the turtle would disappear.
    However, the program does not gave error message but when I click the turtle, there is no effect on it.
    What's wrong with it?
    How can I fix it?
    Mod note: Added code tags.
    My written programme:
    Code (Python):

    import turtle
    import pygame

    def hide():
    Last edited by a moderator: Nov 19, 2016
  2. jcsd
  3. Nov 19, 2016 #2


    Staff: Mentor

    Please use code tags, especially with Python code!
    They look like this
    <your code>
    I don't know anything about turtle graphics in Python, but I suspect if you want to hide the turtle, you first have to make it appear.Have you looked at any documentation for turtle graphics in Python? I did a web search for "python turtle" and found this as the first link: https://docs.python.org/2/library/turtle.html
  4. Nov 19, 2016 #3


    Staff: Mentor

  5. Nov 19, 2016 #4
    According to the documentation the function which is given as argument to onclick should take two arguments representing the coordinates.
  6. Nov 29, 2016 #5
    There is already one turtle when import turtle. I don't think it is a problem if I do not create one more...

    Do you mean I should add a line like "x,y = turtle.pos()"? But I thought "turtle.onclick()" is meaning to click the turtle...
  7. Nov 29, 2016 #6
    No, you don't need. But, your function hide should take to parameters (the coordinates). However, You don't need to do something with these parameters inside the function.
  8. Nov 29, 2016 #7
    Code (Python):

    import turtle
    import pygame
    def hide(x,y):    
    Do you mean like this?
  9. Nov 29, 2016 #8
    Yes. Does it help?
  10. Nov 29, 2016 #9
    The turtle doesn't response when i click on it...
  11. Nov 29, 2016 #10


    Staff: Mentor

    Do you have any more code than what you show in this thread?

    All you're doing in the code here is hiding the turtle. Have you looked at the documentation for turtle graphics? If not, follow this link: https://docs.python.org/3/library/frameworks.html
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Threads - Simple turtle graphic Date
Need some advice on an appropriate computer language to use Feb 13, 2018
Some simple problem with my GUI? Nov 8, 2017
Python Simple python database Sep 19, 2017
Creating a simple text parser/compiler Jun 28, 2017
C/++/# Creating a simple password program in C++ May 19, 2017