【发布时间】:2016-06-07 12:24:29
【问题描述】:
我正在尝试获取冗余检查按钮的状态,以查看是否应该运行 test.py 脚本。正如它现在工作的那样,一旦单击按钮,run.py 就会触发并正常运行 testSomething 函数。每当我尝试使用.get() 或类似的东西来获取状态时,它都会抛出模块对象没有属性错误。知道我做错了什么吗?另外,将 if 语句放在 run.py 文件或 test.py 文件中会更好吗?提前致谢。
Tool.py相关行
类 ToolGui(Frame): def create_widgets(self): self.redundancyChecked = IntVar()
self.redundancyCheckbutton = Checkbutton(rightframe, onvalue=1, offvalue=0, text="Run Script?", variable=self.redundancyChecked)
self.redundancyCheckbutton.pack(side=TOP, pady=(5,0))
run.py相关行
类线程(threading.Thread): def runC(self, varis) :
####if checkbutton is checked, run this...could go here
test.trySomething(workDir)
test.py相关行
import os
import sys
import subprocess
def trySomething(dir):
import Tool
###or If statement could go here, not sure which would be better
Tool.redundancyCheckbutton.config(state=DISABLED)
【问题讨论】:
-
请显示实际错误——它会告诉您哪个模块和哪个属性。根据经验,您应该从字面上理解错误信息并假设它说的是真话。