我试图获取冗余检查按钮的状态,以查看是否应该运行test.py
脚本。当它现在起作用时,一旦点击了一个按钮,run.py
就会关闭并运行testSomething函数。每当我尝试使用.get()
或类似的东西来获取状态时,它会抛出模块对象没有属性错误。任何想法我做错了什么?另外,将if语句放在run.py
文件或test.py
文件中会更好吗?提前致谢。 Tool.py的尝试获取Checkbutton状态时,“模块”对象没有属性错误
相关线路
类ToolGui(帧): DEF create_widgets(个体): 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
class Threading(threading.Thread): DEF runC(个体,瓦里斯):
####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)
请显示实际的错误 - 它告诉你哪个模块和哪个属性。作为一个经验法则,你应该从字面上理解错误信息,并假设它说的是实话。 –