Problema con suma, .get y cuadro de texto para numeros
Publicado por Mateo (4 intervenciones) el 29/09/2017 00:11:39
Alguien sabe como puedo utilizar una caja de texto pero para que me muestre numeros , y colocar el resultado de una suma en el.. al hacerlo me genera error con el .get() y si elimino el .get() en la definicion de la variable el resultado no da.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from tkinter import *
ventana = tk.Tk()
ventana.title("Geometria y Cargas")
ventana.geometry("280x200")
ventana.configure(background="light gray")
lb1 = tk.Label(text="Total = ", background= "light gray").place(x=10,y=10)
lbl2 = tk.Label(text="Numero 1= ", background= "light gray").place(x=65,y=100)
lbl3 = tk.Label(text="Numero 2 = ", background= "light gray").place(x=65,y=120)
Var=tk.StringVar()
Total=tk.Entry(ventana,textvariable=Var,width= 6).place(x= 135,y= 10)
entrada1=tk.Entry(ventana,width= 10).place(x= 135,y= 100)
entrada2=tk.Entry(ventana,width= 10).place(x= 135,y= 120)
def suma():
suma=int(entrada1.get()) + int(entrada2.get())
return Var.set(suma)
btnAceptar=tk.Button(ventana,text="Sumar",width=8, command=suma).place(x=180, y=150)
ventana.mainloop()
Valora esta pregunta


0