The problem seems to be related to the graphics.py version of Python 3.
I downloaded the Python 3 version, renamed it graphics.py, then did the following.
PS C:\Users\jaraco\Desktop> python Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from graphics import * >>> dir() ['BAD_OPTION', 'Circle', 'DEAD_THREAD', 'DEFAULT_CONFIG', 'Entry', 'GraphWin', 'GraphicsError', 'GraphicsObject', 'Image', 'Line', 'OBJ_ALREADY_DRAWN', 'Oval', 'Pixmap', 'Point', 'Polygon', 'Queue', 'Rectangle', 'Text', 'Transform', 'UNSUPPORTED_METHOD', '\_\_builtins\_\_', '\_\_doc\_\_', '\_\_name\_\_', '\_\_package\_\_', 'atexit', 'color_rgb', 'copy', 'os', 'sys', 'test', 'time', 'tk'] >>> error in background error handler: out of stack space (infinite loop?) while executing "::tcl::Bgerror {out of stack space (infinite loop?)} {-code 1 -level 0 -errorcode NONE -errorinfo {out of stack space (infinite loop?) while execu..."
As you can see, I get the same error, and I didn’t even do anything in the module. It seems that the problem is with the library itself, and not with what you are doing in your code.
I will tell the author about this, as he suggests.
I found that I did not receive an error if I just imported a graphics module.
>>> import graphics >>> dir(graphics)
I found that if I did this with your code and then changed the GraphWin links to graphics.GraphWin, Text to graphics.Text and Point to graphics.Point, the problem seemed to disappear and I could run it from the command line.
import graphics def main(): print("This program plots the growth of a 10-year investment.") principal = eval(input("Enter the initial principal: ")) apr = eval(input("Enter the annualized interest rate: ")) win = graphics.GraphWin("Investment Grown Chart", 320, 420) win.setBackground("white") graphics.Text(graphics.Point(20, 230), ' 0.0K').draw(win) graphics.Text(graphics.Point(20, 180), ' 2.5K').draw(win) graphics.Text(graphics.Point(20, 130), ' 5.0K').draw(win) graphics.Text(graphics.Point(20, 80), ' 7.5K').draw(win) graphics.Text(graphics.Point(20, 30), '10.0K').draw(win)
Why should it be? It should not. It seems that the graphics.py module has some side effect that is not working properly.
I suspect that you will not encounter these errors in Python 2.x.