38 lines
865 B
Python
38 lines
865 B
Python
from tkinter import *
|
|
|
|
def add_number():
|
|
num = num_box.get()
|
|
if num.isdigit():
|
|
num_list.insert('end', num)
|
|
num_box.delete(0, 'end')
|
|
num_box.focus()
|
|
else:
|
|
num_box.delete(0, 'end')
|
|
num_box.focus()
|
|
|
|
def clear_list():
|
|
num_list.delete(0, 'end')
|
|
num_box.focus()
|
|
|
|
window = Tk()
|
|
window.title("Lista de Números")
|
|
window.geometry("450x200")
|
|
|
|
label1 = Label(text="Ingresa un número:")
|
|
label1.place(x=20, y=20, width=150, height=25)
|
|
|
|
num_box = Entry()
|
|
num_box.place(x=170, y=20, width=100, height=25)
|
|
num_box.focus()
|
|
|
|
button1 = Button(text="Agregar", command=add_number)
|
|
button1.place(x=300, y=20, width=100, height=25)
|
|
|
|
num_list = Listbox()
|
|
num_list.place(x=170, y=50, width=100, height=100)
|
|
|
|
button2 = Button(text="Limpiar", command=clear_list)
|
|
button2.place(x=300, y=50, width=100, height=25)
|
|
|
|
window.mainloop()
|