';位置参数紧跟关键字参数';Python中的错误

';位置参数紧跟关键字参数';Python中的错误,python,Python,我正在为一个项目编写一个程序,该项目的游戏类似于原子爆炸游戏。然而,我在让按钮开始工作时遇到了问题-第一个要退出的按钮完成了它的功能,但是我试图用第二个按钮调用一个子程序,但它不能,因为当我将子程序作为命令放入时,出现了错误“positional argument Follower keyword argument”。我不确定我是否写错了?代码如下: button_1 = tkinter.Button(frame,text = 'QUIT', width = '6', height = '2',

我正在为一个项目编写一个程序,该项目的游戏类似于原子爆炸游戏。然而,我在让按钮开始工作时遇到了问题-第一个要退出的按钮完成了它的功能,但是我试图用第二个按钮调用一个子程序,但它不能,因为当我将子程序作为命令放入时,出现了错误“positional argument Follower keyword argument”。我不确定我是否写错了?代码如下:

button_1 = tkinter.Button(frame,text = 'QUIT', width = '6', height = '2',command=quit)
button_1.pack(side=LEFT)

button_2 = tkinter.Button(frame,text = 'START', width = '6', height = '2',gridimp(gridcreate,_switch,draw,CellGrid,draw,_eventCoords,handleMouseClick,handleMouseMotion))
button_2.pack(side=LEFT)

exat_window = tkinter.Tk()
exat_window.title('Exploding Atoms')
frame = Frame(exat_window )
frame.pack()

exat_window.mainloop()

在python中使用方法时,需要遵循定义方法签名的位置

首先是位置参数,然后是关键字映射参数。我觉得问题在于你的这一行:

button_2 = tkinter.Button(frame,text = 'START', width = '6', height = '2', gridimp(gridcreate,_switch,draw,CellGrid,draw,_eventCoords,handleMouseClick,handleMouseMotion))
您的
gridimp()
正在做什么,这两个选项中是否有一个是基于您的
gridimp()所做的

button_2 = tkinter.Button(frame, gridimp(gridcreate,_switch,draw,CellGrid,draw,_eventCoords,handleMouseClick,handleMouseMotion),text = 'START', width = '6', height = '2')


gridimp(…)
部分是一个位置参数,它不能放在
文本
宽度
高度
参数之后。您希望该部分做什么?如果该部分应该是命令,那么将其作为关键字参数:
command=gridimp
。你也不应该在那里调用它,你希望它只在点击按钮时被调用;也许你想用lambda来代替
command=lambda:gridimp(…)
button_2 = tkinter.Button(frame,text = 'START', width = '6', height = '2', command=gridimp(gridcreate,_switch,draw,CellGrid,draw,_eventCoords,handleMouseClick,handleMouseMotion))