猛跑小猪
我认为错误出在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,所以你应该使用self而不是testPing显式使用。所以,你的代码应该是: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