擅长:python、mysql、java
<p>我可能要迟到了,但我会把它留在这里,以防有人需要。在类似的情况下,我所做的就是在回调中做我需要的所有事情,以写入链接到spinbox的变量。比如:</p>
<pre><code>import Tkinter as tk
root = tk.Tk()
my_var = tk.IntVar() # or whatever you need
spin = tk.Spinbox(root, from_=0, to=100, textvariable=my_var)
spin.pack()
def do_whatever_I_need(*args):
# here I can access the Spinbox value using spin.get()
# I can do whatever check I
my_var.trace('w', whatever) #'w' for "after writing"
</code></pre>
<p>由<code>trace</code>方法创建的回调调用给定函数,其中有两个参数:回调模式(在本例中是<code>'w'</code>)和变量名(这是我从未使用过的某个内部tkinter标识符)。这就是<code>do_wahtever_I_need</code>的签名是<code>*args</code>的原因。在</p>