Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- from tkinter import ttk
- def sumar_numeros():
- x = float(a.get())
- y = float(b.get())
- suma = x + y
- print(suma)
- resultado.set(str(suma))
- # borro las cajas
- a.delete(0,tk.END)
- b.delete(0,tk.END)
- ################### ventana #######################################
- ventana = tk.Tk()
- resultado = tk.StringVar()
- resultado.set("0")
- ventana.title("SUMADOR")
- ventana.config(width=600, height=300)
- ventana.resizable(0,0)
- # campo primer sumando
- a = ttk.Entry()
- a.place(x=40, y=10)
- etiqueta = tk.Label(text="1º sumando")
- etiqueta.place(x=40, y=40)
- # campo segundo sumando
- b = ttk.Entry()
- b.place(x=200, y=10)
- etiqueta = tk.Label(text="2º sumando")
- etiqueta.place(x=200, y=40)
- # campo resultado
- total = tk.Entry(
- font=('arial',20,'bold'),
- state = tk.DISABLED,
- textvariable = resultado,
- bg = "lime green",
- justify = 'right'
- )
- total.place(x=100, y=90)
- etiqueta = tk.Label(text="Total")
- etiqueta.place(x=100, y=150)
- boton = ttk.Button(text="SUMAR", command=sumar_numeros)
- boton.place(x=100, y=200)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement