python_by_example/tkgui/sols_124-132/sol_04.py

34 lines
759 B
Python
Raw Normal View History

2023-11-17 13:26:09 -03:00
from tkinter import *
def add_name():
name = name_box.get()
name_list.insert('end', name)
name_box.delete(0, 'end')
name_box.focus()
def clear_list():
name_list.delete(0, 'end')
name_box.focus()
window = Tk()
window.title("Lista Nombres")
window.geometry("400x200")
labell1 = Label(text="Agregar:")
labell1.place(x=20, y=20, width=100, height=25)
name_box = Entry()
name_box.place(x=120, y=20, width=100, height=25)
name_box.focus()
button1 = Button(text="Agregar", command=add_name)
button1.place(x=250, y=20, width=100, height=25)
name_list = Listbox()
name_list.place(x=120, y=50, width=100, height=100)
button2 = Button(text="Borrar", command=clear_list)
button2.place(x=250, y=50, width=100, height=25)
window.mainloop()