teslariu

arrojar dado

Oct 24th, 2022
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Arrojar un dado
  6. """
  7. import tkinter as tk
  8.  
  9.  
  10. def clic():
  11.     import random
  12.     valor = random.randint(1,6)
  13.     caja_dado.delete(0,tk.END)
  14.     caja_dado.insert(0,valor )
  15.  
  16.    
  17.  
  18. ventana = tk.Tk()
  19. ventana.config(width=200, height=150)
  20. ventana.title("FORMULARIO")
  21. # prohibo redimensionar la ventana
  22. ventana.resizable(False, False)
  23.  
  24.  
  25. etiqueta = tk.Label(text="Valor del dado")
  26. etiqueta.place(x=20, y=10)
  27. caja_dado = tk.Entry()
  28. caja_dado.place(x=120, y=10, width=20, height=25)
  29.  
  30.  
  31.  
  32. # BOTON
  33. boton = tk.Button(text="Arrojar dado", command=clic)
  34. boton.place(x=20, y=80, width=120, height=40)
  35.  
  36.  
  37. ventana.mainloop()
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment