Advertisement
teslariu

tkinter

Sep 8th, 2022
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # tkinter es un binding de tcl/Tk
  5. #
  6. import tkinter as tk
  7.  
  8. def guardar_nombre():
  9.     nombre = caja_nombre.get()
  10.     print(nombre)
  11.  
  12.  
  13.  
  14. ventana = tk.Tk()
  15.  
  16. ventana.config(width=600, height=600)
  17. # ventana.minsize(300,300)      # tamaño mínimo permitido
  18. # evitar el redimensionamiento de la ventana
  19. # ventana.resizable(0,0)
  20. ventana.title("Mi primera app")
  21. ventana.iconbitmap("icono.ico")
  22.  
  23. # Crearemos un campo "nombre" para almacenar un nombre
  24. etiqueta = tk.Label(text="Nombre")
  25. etiqueta.place(x=20, y=25)
  26. caja_nombre = tk.Entry()
  27. caja_nombre.place(x=100, y=25, width=200, height=25)
  28.  
  29. # Creo un botón
  30. boton = tk.Button(text="Guardar", command=guardar_nombre)
  31. boton.place(x=70, y=80, width=120, height=50)
  32.  
  33. ventana.mainloop()
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement