Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python3 Tkinter UI中尝试使用变量时遇到问题_Python - Fatal编程技术网

在Python3 Tkinter UI中尝试使用变量时遇到问题

在Python3 Tkinter UI中尝试使用变量时遇到问题,python,Python,在exec path行上的predict标志之后,我一直在尝试使用变量“我需要选定要打印的文件夹的路径名” def clicked(): folder_selected = filedialog.askdirectory() exec(Path("whatevascript.py --weights weights.h5 predict (folder_selected)").read_text()) Python匿名函数(Lambda函数) 您将需要使用lambda表达式作为

在exec path行上的predict标志之后,我一直在尝试使用变量“我需要选定要打印的文件夹的路径名”

def clicked():
    folder_selected = filedialog.askdirectory()
    exec(Path("whatevascript.py --weights weights.h5 predict (folder_selected)").read_text())
Python匿名函数(Lambda函数) 您将需要使用lambda表达式作为命令参数的参数,该参数在单击的按钮中调用此单击函数,它将如下所示

Button(root, text="Click me", command=lambda :clicked(VARIABLE))
由于无法将参数传递给函数,因此,您将向命令参数提供函数指针