擅长:python、mysql、java
<p>如果将<code>command</code>参数赋给调用另一个函数的lambda函数,怎么样:</p>
<pre><code>Button(master,text="show the slider", command=lambda: bool_func(bool1show).place(x=800,y=10)
Button(master,text="hide the slider",command=lambda: bool_func(bool1show,b=False).place(x=900,y=10)
</code></pre>
<p>其中:</p>
<pre><code>def bool_func(variable, b=True): # b is True by default, hence you don't provide the argument in the first Button statement.
variable = b
return variable
</code></pre>
<p>有关lambda函数的一些信息,请查看<a href="http://www.diveintopython.net/power_of_introspection/lambda_functions.html" rel="nofollow">here</a></p>