[Tutor] Fwd: Fwd: : Turtle
Hershel Millman
hershellearningcode at gmail.com
Fri Jun 24 03:51:39 EDT 2016
Python didn't come installed on my Mac, my dad had to install it. I typed
import Tkinter into the terminal and received no error message, and when I
ran it in pycharm, I also received no error message. I found a little
program online and ran it to test the functionality of Tkinter, and it
worked.
from Tkinter import *
class Application(Frame):
def say_hi(self):
print "hi there, everyone!"
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi
self.hi_there.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
and it finished with exit code 0.
I just tried to use turtle in pycharm again, and for some reason it worked
with exit code 0.
I typed:
from turtle import *
speed('fastest')
i = 0
while i < 1:
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(91)
i += 1
input()
and it gave me no error message.
However, when I typed the same thing, except instead of "from turtle import
*", I typed "import turtle," I got this error message:
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
"/Users/Hershel/PycharmProjects/Project 1/notturtle.py"
Traceback (most recent call last):
File "/Users/Hershel/PycharmProjects/Project 1/notturtle.py", line 2, in
<module>
speed('fastest')
NameError: name 'speed' is not defined
Process finished with exit code 1
How do I make it so pycharm is using python version 2.6 instead of 2.5?
(I have python 2.6 in the same "versions" folder as 2.5)
Thank you,
Hershel
---------- Forwarded message ----------
From: *Alan Gauld via Tutor* <tutor at python.org>
Date: Friday, June 24, 2016
Subject: [Tutor] Fwd: : Turtle
To: tutor at python.org
On 24/06/16 03:02, Hershel Millman wrote:
> It tells me:
> Trace back (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'turtle' is not defined
As I recall, the default install of Python on a Mac
does not include Tkinter. Turtle uses Tkinter so I
suspect turtle is not installed either.
To confirm that try
import Tkinter
and see if that also gives an error.
If I'm right you will need to ensure you use the
2.6 version for all your turtle stuff.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list