Note that there are some explanatory texts on larger screens.

plurals
  1. POBeginner graphics program in Python giving 'out of stack space' error
    primarykey
    data
    text
    <p>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 <a href="http://mcsp.wartburg.edu/zelle/python" rel="nofollow noreferrer">http://mcsp.wartburg.edu/zelle/python</a> and renaming it graphics.py on my computer.</p> <p>The file named futval_graph.py is as follows:</p> <pre><code>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() </code></pre> <p>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:</p> <blockquote> <p>C:\Python31>futval_graph.py<br> This program plots the growth of a 10-year investment.<br> Enter the initial principal: error in background error handler:<br> out of stack space (infinite loop?)<br> while executing<br> "::tcl::Bgerror {out of stack space (infinite loop?)} {-code 1 -level 0 -errorco de NONE -errorinfo {out of stack space (infinite loop?)<br> while execu..." </p> </blockquote> <p>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.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload