<p>可以使用<code>IntVar</code>将数字调整框连接到Python变量。我用一个例子扩展了你的程序。它添加了一个按钮来打印数字调整框的当前值:</p>
<pre><code>from tkinter import *
windowTk = Tk()
pwMain = PanedWindow(windowTk, orient=VERTICAL)
pwTop = PanedWindow(pwMain, orient=HORIZONTAL)
lignes = IntVar(windowTk, value=0)
colonnes = IntVar(windowTk, value=0)
def print_vars():
print(lignes.get(), colonnes.get())
def configTables() :
sLine = Spinbox(pwTop, from_=0, to=15, textvariable=lignes)
pwTop.add( Label(pwTop, text = "Combien y a-t-il de lignes de table ?") )
pwTop.add( sLine )
sColumn = Spinbox(pwTop, from_=0, to=15, textvariable=colonnes)
pwTop.add( Label(pwTop, text = "Combien y a-t-il de colonnes de tables ?") )
pwTop.add( sColumn )
pwTop.pack()
b = Button(pwMain, text='print', command=print_vars)
b.pack(side=BOTTOM)
pwMain.pack()
global coordTables
coordTables = []
coordTables.append( int(sLine.get()) )
coordTables.append( int(sColumn.get()) )
return coordTables
print( configTables() )
windowTk.mainloop()
</code></pre>
<p>注意,我没有删除不再需要的东西,比如<code>coordTables</code>变量和return语句。在</p>