python - Tkinter - SyntaxError:关键字arg之后的非关键字arg
问题描述
我有这个我无法理解的问题,所以在删除按钮中,我在创建按钮后尝试删除按钮,我有这个错误:
Delete=Button(root,text='Delete',command=lambda : S.pack_forget(),T.pack_forget())
SyntaxError: non-keyword arg after keyword arg
代码:
from Tkinter import *
root=Tk()
Menubar = Menu(root)
root.config(menu=Menubar)
def CreateButton():
S=Button(root,text='Second Boton')
S.pack(side='right')
T=Button(root,text='Third Boton')
T.pack(side='right')
Delete=Button(root,text='Delete',command=lambda : S.pack_forget(),T.pack_forget())
Delete.pack(side='right')
Create=Button(root,text='Create Boton',command=CreateButton)
Create.pack(side='left')
root.mainloop()
解决方案
您必须在命令中输入“[]”才能使用多个命令。只需编辑它:
Delete=Button(root,text='Delete',command=lambda : S.pack_forget(),T.pack_forget())
至 :
Delete=Button(root,text='Delete',command=lambda : [S.pack_forget(),T.pack_forget()])
推荐阅读
- c++ - 有没有一种方法可以支持使用 c++ 在 libreoffice calc sdk 中显示汉字?
- javascript - JavaScript 2D 数组,如果输入 RegEx 匹配 col1 ,则返回 col2
- python - 进步
这一切都很好,但我想要做的是将我上传的文件的名称存储在隐藏的输入类型中,所以当我提交带有文本字段的表单时,图像的名称可以提交到数据库。
我注意到当我将主表单提交到数据库时,图像已保存到数据库中。我可以将它保存在一个名为“媒体”的临时文件夹中。但是,每当我编辑表单时,图像就无法再检
- java - 来自控制器 JSP 的错误响应
- python - 有没有办法可以在一个列标题下嵌套两列数据?
- javascript - 如何使用 javascipt 以编程方式(单击按钮)为 django-select2 字段设置值?
- amazon-web-services - Amazon Cloud - 目标组已删除
- linux - 如何为我找到的每个文件执行多个命令
- laravel - 如何使用 laravel JsonResource 为多态关系生成 json 响应
- wordpress - 在 WooCommerce 的商店页面上显示销售商品