Advertisement
teslariu

tk

Sep 17th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5.  
  6. def guardar():
  7.     global nombres
  8.     nombre = caja.get()
  9.     nombres.append(nombre)
  10.     print(nombres)
  11.     caja.delete(0,tk.END)
  12.  
  13.  
  14. nombres = []
  15.  
  16.  
  17. ventana = tk.Tk()
  18. ventana.config(width=400, height=300)
  19. ventana.title("Mi primera app")
  20. ventana.resizable(0, 0)
  21.  
  22. # agreguemos un boton
  23. boton = tk.Button(
  24.         text="Guardar",
  25.         bg="green",
  26.         fg="white",
  27.         command=guardar)
  28. boton.place(x=20, y=50, width=100, height=50)
  29.  
  30. # agreguemos una caja para ingresar texto
  31. caja = tk.Entry(bg="yellow", font=['arial',15,'bold', 'italic'], fg="blue")
  32. caja.place(x=20, y=140, width=200, height=25)
  33.  
  34. # agrego una etiqueta fija
  35. etiqueta = tk.Label(text="Ingrese su nombre")
  36. etiqueta.place(x=240, y=140)
  37.  
  38. ventana.mainloop()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement