GUIを作成していますが、変数で何かが起こっています。
それは、値シータを計算することから始まります。これは、ボタンをクリックすると、入力フィールドに渡されます(これは関数に書き込まれます:) thetaVar.set(CalcTheta(grensVar.get(), data[:,1], data[:,2]))
。
thetaVar = IntVar()
def callbackTheta(name, index, mode):
thetaValue = nGui.globalgetvar(name)
nGui.globalsetvar(name, thetaValue)
wtheta = thetaVar.trace_variable('w', callbackTheta)
rtheta = thetaVar.trace_variable('r', callbackTheta)
entryTheta = Entry(textvariable=thetaVar).place(x=90, y=202)
これは機能しますが([入力]フィールドに値が表示されます)、後でこの値を取得しようとすると機能しません。私はすべてを試したと思います:
thetaVar.get() # with print, returns the integer 0, this is the initial value
# that is displayed, even though at that moment it shows 0.4341.
thetaVar # with print, returns 'PY_VAR3'
thetaValue # with print, global value not defined
entryTheta.get() # AttributeError: 'NoneType' object has no attribute 'get'
rtheta # print returns: 37430496callbackTheta
この値がどこに格納されているのか、別の関数でエントリの値をどのように使用できるのかわかりません。実際の直後にこれらのいずれかを試しても.set
、エントリのこの特定の値を直後に印刷できないようです。
Windows8でのtkinterとPython3.3の使用。