0% found this document useful (0 votes)
31 views3 pages

Calculadora Tkinter

Uploaded by

sanelpaisa01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views3 pages

Calculadora Tkinter

Uploaded by

sanelpaisa01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

from tkinter import *

from tkinter import ttk

def sumar():

numero1 = int(txt1.get())

numero2 = int(txt2.get())

suma= numero1 + numero2

return total.set(suma)

def restar():

numero1 = int(txt1.get())

numero2 = int(txt2.get())

resta= numero1 - numero2

return total.set(resta)

def multiplicar():

numero1 = int(txt1.get())

numero2 = int(txt2.get())

multiplicacion= numero1 * numero2

return total.set(multiplicacion)

def dividir():

numero1 = int(txt1.get())

numero2 = int(txt2.get())

division= numero1 / numero2


return total.set(division)

windowp = Tk()

windowp.title("Calculadora Básica")

windowp.geometry("400x400")

windowp.resizable(False,False)

windowp.config(bg="wheat2")

label1 = Label(windowp, text= "Ingrese un número", bg="burlywood4", fg="white" )

label1.pack(padx=5, pady=3, ipadx=5, ipady=5,fill=X)

txt1 = Entry(windowp)

txt1.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

label2 = Label(windowp, text= "Ingrese un segundo número", bg="burlywood4", fg="white" )

label2.pack(padx=5, pady=3, ipadx=5, ipady=5,fill=X)

txt2 = Entry(windowp)

txt2.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

btnsumar = Button(windowp, text="Sumar", bg="cornsilk4", command=sumar)

btnsumar.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

btnrestar = Button(windowp, text="Restar", bg="cornsilk4", command=restar)


btnrestar.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

btnmultiplicar = Button(windowp, text="Multiplicar", bg="cornsilk4", command=multiplicar)

btnmultiplicar.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

btndividir = Button(windowp, text="Dividir", bg="cornsilk4", command=dividir)

btndividir.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

labelresult = Label(windowp, text= "Resultado de la suma", bg="burlywood4", fg="white" )

labelresult.pack(padx=5, pady=3, ipadx=5, ipady=5,fill=X)

total = StringVar()

txtresult = Entry(windowp, textvariable=total)

txtresult.pack(padx=5, pady=3, ipadx=5, ipady=5, fill=X)

windowp.mainloop()

You might also like