-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculadora_Benas.py
More file actions
108 lines (80 loc) · 4.25 KB
/
Copy pathCalculadora_Benas.py
File metadata and controls
108 lines (80 loc) · 4.25 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Calculadora Benas
#impoortando tkinter
import tkinter
from tkinter import *
from tkinter import ttk
#Cores
cor1="#0a0b0a"#preta
cor2="#fbfbfb"#branca
cor3="#bac8dd"#azul
cor4="#9c9b9f"#cinza
cor5="#eb8c0e"#laranja
janela= Tk()
janela.title("Calculadora Benas")
janela.geometry("235x310")
janela.config(bg=cor1)
#criando frames
frame_tela= Frame(janela,width=235,height=50,bg=cor3)
frame_tela.grid(row=0,column=0)
frame_corpo= Frame(janela,width=235,height=268)
frame_corpo.grid(row=1,column=0)
#variavel todos os valores
todos_valores=''
#Criando função
def entrar_valores(event):
global todos_valores
todos_valores=todos_valores+ str(event)
#passando valor para tela
valor_texto.set(todos_valores)
#função para calcular
def calcular():
global todos_valores
resultado=str(eval(todos_valores))
valor_texto.set(resultado)
#Função limpar tela
def limpar_tela():
global todos_valores
todos_valores=""
valor_texto.set("")
# Criando Labels
valor_texto=StringVar()
app_label=Label(frame_tela,textvariable=valor_texto,width=16,height=2,padx=7,relief=FLAT,anchor="e",justify=RIGHT,font=('Ivy 18'),bg=cor3,fg=cor1)
app_label.place(x=0,y=0)
#Criando botões
b_1=Button(frame_corpo,command=lambda:limpar_tela(),text="C",width=11,height=2,bg=cor4,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_1.place(x=0,y=0)
b_2=Button(frame_corpo,command=lambda:entrar_valores('%'),text="%",width=5,height=2,bg=cor4,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_2.place(x=118,y=0)
b_3=Button(frame_corpo,command=lambda:entrar_valores('/'),text="/",width=5,height=2,bg=cor5,fg=cor2,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_3.place(x=177,y=0)
b_4=Button(frame_corpo,command=lambda:entrar_valores('7'),text="7",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_4.place(x=0,y=52)
b_5=Button(frame_corpo,command=lambda:entrar_valores('8'),text="8",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_5.place(x=59,y=52)
b_6=Button(frame_corpo,command=lambda:entrar_valores('9'),text="9",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_6.place(x=118,y=52)
b_7=Button(frame_corpo,command=lambda:entrar_valores('*'),text="*",width=5,height=2,bg=cor5,fg=cor2,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_7.place(x=177,y=52)
b_8=Button(frame_corpo,command=lambda:entrar_valores('4'),text="4",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_8.place(x=0,y=104)
b_9=Button(frame_corpo,command=lambda:entrar_valores('5'),text="5",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_9.place(x=59,y=104)
b_10=Button(frame_corpo,command=lambda:entrar_valores('6'),text="6",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_10.place(x=118,y=104)
b_11=Button(frame_corpo,command=lambda:entrar_valores('-'),text="-",width=5,height=2,bg=cor5,fg=cor2,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_11.place(x=177,y=104)
b_12=Button(frame_corpo,command=lambda:entrar_valores('1'),text="1",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_12.place(x=0,y=156)
b_13=Button(frame_corpo,command=lambda:entrar_valores('2'),text="2",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_13.place(x=59,y=156)
b_14=Button(frame_corpo,command=lambda:entrar_valores('3'),text="3",width=5,height=2,bg=cor4,fg=cor1,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_14.place(x=118,y=156)
b_15=Button(frame_corpo,command=lambda:entrar_valores('+'),text="+",width=5,height=2,bg=cor5,fg=cor2,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_15.place(x=177,y=156)
b_16=Button(frame_corpo,command=lambda:entrar_valores('0'),text="0",width=11,height=2,bg=cor4,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_16.place(x=0,y=208)
b_17=Button(frame_corpo,command=lambda:entrar_valores('.'),text=".",width=5,height=2,bg=cor4,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE)
b_17.place(x=118,y=208)
b_18=Button(frame_corpo,command=lambda:calcular(),text="=",width=5,height=2,bg=cor5,fg=cor2,font='Ivy 13 bold',relief=RAISED,overrelief=RIDGE )
b_18.place(x=177,y=208)
janela.mainloop()