SHARE
TWEET

Untitled

a guest Feb 18th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2.  
  3. raiz = Tk()
  4.  
  5. miframe = Frame(raiz)
  6.  
  7. miframe.pack()
  8.  
  9. # ------- pantalla --------- #
  10.  
  11. numeroPantalla = StringVar()
  12.  
  13.  
  14. pantalla = Entry(miframe, textvariable = numeroPantalla)
  15. pantalla.grid(row = 1, column = 1, padx = 10, pady = 10, columnspan = 4)
  16. pantalla.config(background = "black", fg = "#52e970", justify = "right")
  17.  
  18.  
  19.  
  20. # ------ pulsaciones teclado ----#
  21.  
  22. def numeroPulsado(num):
  23.  
  24.     numeroPantalla.set(numeroPantalla.get()+num)
  25.  
  26. # ------ fila 1 ------------ #
  27.  
  28. boton7 = Button(miframe, text = "7", width = 3, command = lambda:numeroPulsado("7"))
  29. boton7.grid(row = 2, column = 1)
  30. boton8 = Button(miframe, text = "8", width = 3, command = lambda:numeroPulsado("8"))
  31. boton8.grid(row = 2, column = 2)
  32. boton9 = Button(miframe, text = "9", width = 3, command = lambda:numeroPulsado("9"))
  33. boton9.grid(row = 2, column = 3)
  34. div = Button(miframe, text = "/", width = 3)
  35. div.grid(row = 2, column = 4)
  36.  
  37. # ------ fila 2 ------------ #
  38.  
  39. boton4 = Button(miframe, text = "4", width = 3, command = lambda:numeroPulsado("4"))
  40. boton4.grid(row = 3, column = 1)
  41. boton5 = Button(miframe, text = "5", width = 3, command = lambda:numeroPulsado("5"))
  42. boton5.grid(row = 3, column = 2)
  43. boton6 = Button(miframe, text = "6", width = 3, command = lambda:numeroPulsado("6"))
  44. boton6.grid(row = 3, column = 3)
  45. mult = Button(miframe, text = "X", width = 3)
  46. mult.grid(row = 3, column = 4)
  47.  
  48. # ------ fila 1 ------------ #
  49.  
  50. boton1 = Button(miframe, text = "1", width = 3, command = lambda:numeroPulsado("1"))
  51. boton1.grid(row = 4, column = 1)
  52. boton2 = Button(miframe, text = "2", width = 3, command = lambda:numeroPulsado("2"))
  53. boton2.grid(row = 4, column = 2)
  54. boton3 = Button(miframe, text = "3", width = 3, command = lambda:numeroPulsado("3"))
  55. boton3.grid(row = 4, column = 3)
  56. rest = Button(miframe, text = "X", width = 3)
  57. rest.grid(row = 4, column = 4)
  58.  
  59.  
  60. # ------ fila 0 ------------ #
  61.  
  62. boton0 = Button(miframe, text = "0", width = 3, command =  lambda:numeroPulsado("0"))
  63. boton0.grid(row = 5, column = 1)
  64. botoncoma = Button(miframe, text = ",", width = 3)
  65. botoncoma.grid(row = 5, column = 2)
  66. botonigual = Button(miframe, text = "=", width = 3)
  67. botonigual.grid(row = 5, column = 3)
  68. suma = Button(miframe, text = "+", width = 3)
  69. suma.grid(row = 5, column = 4)
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. raiz.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top