1 回答

TA貢獻1858條經(jīng)驗 獲得超8個贊
我認為錯誤出在testPing課堂上;特別是在這些方面:
class testPing(tk.Frame):
...
clearFileRadioYes = tk.Radiobutton(self, text="yes", value=True, var=clearFile,
command=lambda: testPing.callback(clearFile.get()))
clearFileRadioYes.pack(anchor="w")
clearFileRadioNo = tk.Radiobutton(self, text="no", value=False, var=clearFile,
command=lambda: testPing.callback((clearFile.get())))
clearFileRadioNo.pack(anchor="w")
urlSubmitButton = tk.Button(self, text="Submit",
command=lambda: testPing.pingURL(urlInputBox.get(),
testPing(clearFile.get())))
你在里面testPing,所以你應(yīng)該使用self而不是testPing顯式使用。所以,你的代碼應(yīng)該是:
class testPing(tk.Frame):
...
clearFileRadioYes = tk.Radiobutton(self, text="yes", value=True, var=clearFile,
command=lambda: self.callback(clearFile.get()))
clearFileRadioYes.pack(anchor="w")
clearFileRadioNo = tk.Radiobutton(self, text="no", value=False, var=clearFile,
command=lambda: self.callback((clearFile.get())))
clearFileRadioNo.pack(anchor="w")
urlSubmitButton = tk.Button(self, text="Submit",
command=lambda: self.pingURL(urlInputBox.get(),
clearFile.get()))
注意使用self而不是testPing
添加回答
舉報