Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is here:</p> <pre><code>calculate_button = Button(text='Calculate', command=solfield()) </code></pre> <p>To pass the function <code>solfield</code> itself as the <code>command</code>, just use its name:</p> <pre><code>calculate_button = Button(text='Calculate', command=solfield) </code></pre> <p>What you're doing is <em>calling</em> the function, and then passing the return value of that function as the command.</p> <p>Since you defined <code>solfield</code> above as do-nothing function, that return value is <code>None</code>, so you're telling <code>calculate_button</code> that its <code>command=None</code>, and it's properly doing nothing.</p> <hr> <p>Meanwhile, as SethMMorton pointed out (but then deleted):</p> <blockquote> <p>You have two functions named <code>solfield</code>, and you are naming a variable <code>solfield</code> in one of your <code>solfield</code> functions. Remove the empty function (the one with pass), and using a different variable name in the remaining function.</p> </blockquote> <p>This isn't causing your actual problem, but it's certainly adding to the confusion that makes it harder for you to <em>find</em> the problem. (For example, if you hadn't included the excess empty definition of <code>solfield</code> at all, you would have gotten a <code>NameError</code> in the incorrect line, which would have made things easier to debug.)</p> <hr> <p>Putting it all together, what you should do is:</p> <ol> <li>Get rid of the empty (<code>pass</code>-only) definition of <code>solfield</code>.</li> <li>Move the real implementation of <code>solfield</code> up above the point where you build the GUI.</li> <li>Don't name a local variable <code>solfield</code> within the function.</li> <li>Pass just <code>solfield</code>, not <code>solfield()</code> as the <code>command</code> for <code>calculate_button</code>.</li> </ol>
 

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