Python Forum

Full Version: turtle window not showing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am new trying to learn python.

For the turtle, I actually copied the following code and tried to run on Pycharm community 2020 1.1 version just to learn.
The code is from google and actually run by someone:
import turtle
def main():
wn = turtle.Screen()
alex = turtle.Turtle()
alex.forward(150)
alex.left(90)
alex.forward(75)
wn.exitonclick()

But when I clicked run, as seen from you tube the python graphic (or canvas or window, however you call it) will pop up and draw whatever code, but in my case it didn't pop up at all.
It just showed:
'Process finished with exit code 0'
I tried different codes but the window still not popping up.
Can I know what is missing from the installation?
Please advise, appreciate your help.
First you need to import the module, then after defining your code you need to allow it to execute.
See the code example below:
import turtle

def main():
    wn = turtle.Screen()
    alex = turtle.Turtle()
    alex.forward(150)
    alex.left(90)
    alex.forward(75)
    wn.exitonclick()
if __name__=='__main__':
    main()
Got it thanks.
Also @yokeloonlo01 please use proper coding tags in future threads & posts