I'm currently learning Python using Zelle's Introductory text, and I'm trying to recreate one of the example programs which uses an accompanying file graphics.py. Because I'm using Python 3.1 and the text was written for 2.x though, I'm using the GraphicsPy3.py file found at http://mcsp.wartburg.edu/zelle/python and renaming it graphics.py on my computer.
The file named futval_graph.py is as follows:
from graphics import *
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 = GraphWin("Investment Grown Chart", 320, 420)
win.setBackground("white")
Text(Point(20, 230), ' 0.0K').draw(win)
Text(Point(20, 180), ' 2.5K').draw(win)
Text(Point(20, 130), ' 5.0K').draw(win)
Text(Point(20, 80), ' 7.5K').draw(win)
Text(Point(20, 30), '10.0K').draw(win)
# Rest of code is here but I've commented it out to isolate the problem.
main()
When I run 'import futval_graph' on a fresh IDLE session the program simply runs and then hangs after inputing 'apr' without opening the new graphics window. When I run the program from the command line I get the following result:
C:\Python31>futval_graph.py
This program plots the growth of a 10-year investment.
Enter the initial principal: 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 -errorco de NONE -errorinfo {out of stack space (infinite loop?)
while execu..."
Especially frustrating is the fact that this series of commands works when entered into a fresh session of IDLE. And then when running 'import futval_graph' from IDLE after all of the commands have been run on their own, futval_graph works properly.
So my question is: how can I get futval_graph.py to run properly both from the command line and IDLE? Sorry if my explanation of the problem is a bit scattered. Let me know if any further info would help clarify.