我有一个Python文件,其他文件调用该文件。每次从其他文件导入并调用mainApp时,Python文件内的tkinter按钮会自动执行。以下是Python文件的一部分代码:
from Tktable import *
def exp(Output):
import csv
from tkFileDialog import askdirectory
folder=askdirectory();
if folder:
path = folder+'/outputTable.csv';
file = open(path, 'w');
writer = csv.writer(file)
title = ['Premise','Conclusion','Support','Confidence','Lift']
writer.writerow(title);
zip(*Output)
for item in zip(*Output):
writer.writerow(item)
file.close()
def mainApp(Output):
from Tkinter import Tk, Label, Button, Scrollbar, Frame
root = Tk()
top = Frame(root).pack(side = 'top', fill = 'x')
...
export = Button(top, text='EXPORT', command=exp(Output))
export.grid(row=0, column=4, sticky = 'e')
...
我该如何停止按钮的自动执行?为什么会发生这种情况?有人能帮忙吗?谢谢!