python tkinter替换按钮onclick in CONTRICK将在按下Enter后将转向输入输入的输入
我正在尝试使用一个tkinter按钮,即单击时,用 用 tk.entry()
,然后按下输入
在条目中,该条目被A new 按钮,该按钮具有条目的文字( entry.get.get())...
这是我的代码:
import tkinter as tk
root = tk.Tk()
root.geometry("300x200")
def func(neww):
b = tk.Button(root, text=neww, command=onclick)
b.grid(row=0, column=0)
def onclick():
e = tk.Entry(root)
e.grid(row=0, column=0)
e.bind('<Return>', func(e.get()))
b = tk.Button(root, text='clickme', command=onclick)
b.grid(row=0, column=0)
root.mainloop()
由于某种原因,我无法发布照片,但结果是条目和buttos重叠,
以及正在创建的新按钮 onfocus
而不是返回
事件时。
这些代码是两个分开的问题,我真的很感谢两者的帮助:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单击按钮时,您需要 hide 按钮并创建条目框。
当您按 Enter 键时,请更新隐藏按钮的文本,销毁输入框,然后显示回到按钮。
When the button is clicked, you need to hide the button and create the entry box.
When you press Enter key, update the text of the hidden button, destroy the entry box and then show back the button.