-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculadora_Form.py
More file actions
61 lines (44 loc) · 1.56 KB
/
Calculadora_Form.py
File metadata and controls
61 lines (44 loc) · 1.56 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import tkinter as tk
gui=tk.Tk()
gui.title("Formulario Calculadora")
gui.geometry("500x500")
class Calculadora(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.create_widgets()
self.pack()
def soma(self, a, b):
print(a + b)
def subtrai(self,a,b):
return a - b
def multiplica(self,a,b):
return a * b
def divide(self,a,b):
return a / b
def create_widgets(self):
self.entrada1 = tk.Entry(self)
self.entrada1.pack()
self.entrada2 = tk.Entry(self)
self.entrada2.pack()
self.conteudo1 = tk.StringVar(self)
self.conteudo2 = tk.StringVar(self)
self.entrada1["textvariable"] = self.conteudo1
self.entrada2["textvariable"] = self.conteudo2
self.button1 = tk.Button(self)
self.button1["text"] = "Somar"
self.button1["command"] = lambda: self.soma(float(self.conteudo1.get()), float(self.conteudo2.get()))
self.button1.pack()
self.button2 = tk.Button(self)
self.button2["text"] = "Subtrair"
self.button2["command"] = lambda: self.subtrai(float(self.conteudo1.get()), float(self.conteudo2.get()))
self.button2.pack()
self.button3 = tk.Button(self)
self.button3["text"] = "Multiplicar"
self.button3["command"] = lambda: self.multiplica(float(self.conteudo1.get()), float(self.conteudo2.get()))
self.button3.pack()
self.button4 = tl.Button(self)
self.button4["text"] = "Dividir"
self.button4["command"] = lambda: self.multiplica(float(self.conteudo1.get()), float(self.conteudo2.get()))
self.button4.pack()
gui.mainloop()