我正在尝试从条目小部件中删除文本,但这是行不通的...
我该如何解决?我分开了框架:
frame0->标签和条目
frame1->按钮
这对它有何影响?预先感谢eliran。
import tkinter
import tkinter.ttk
def custom_link():
window4 = tkinter.Toplevel()
window4.geometry("650x100")
frame0 = tkinter.ttk.Frame(window4)
frame0.grid(row=0, column=0)
frame1 = tkinter.ttk.Frame(window4)
frame1.grid(row=1, column=0)
link_text_label = tkinter.ttk.Label(frame0, text="Enter link: ")
link_text_label.grid(row=0, column=0, sticky='w',padx=5)
link_entry = tkinter.Entry(frame0, width=60, foreground="blue", font=("ariel",11))
link_entry.grid(row=0, column=1, sticky='w', padx=1, pady=3 )
save_link = tkinter.ttk.Button(frame1, text="Save", command=None)
save_link.grid(row=0, column=0, sticky='w', padx=5)
clear_text_btn = tkinter.ttk.Button(frame1, text="Clear", command= link_entry.delete(0, 'end') )
clear_text_btn.grid(row=0, column=1, sticky='w', padx=5)
window = tkinter.Tk()
window.geometry("150x100")
frame = tkinter.ttk.Frame(window)
frame.grid(row=0, column=0)
Btn = tkinter.ttk.Button(window, text="button", command = custom_link)
Btn.grid(row=0, column=0)
window.mainloop()