Python | Trigonometry

/ 29 Jul 2013 /
So we're FINALLY learning trigo, so I thought to myself, why not make an app about it (I NEED TO STOP THAT)
'Pen-itrator' Ikr

here is the wonderful code.

 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
import sys
from tkinter import *
from math import *


def test():
    OPP = ment.get()
    HYP = ment1.get()
    ADJ = ment2.get()
    Sin = OPP + '/' + HYP
    Cos = ADJ + '/' + HYP
    Tan = OPP + '/' + ADJ
    mlabel['text'] = 'sin = ' + Sin
    mlabel1['text'] = 'cos = ' + Cos
    mlabel2['text'] = 'tan = ' + Tan

app = Tk()
app.title('Pen-itrator')
app.geometry('800x600')


#Variables
ment = StringVar()
ment1 = StringVar()
ment2 = StringVar()

#Button
mbutton = Button(app, text = 'SIN!', command = test)
mbutton.place(x=5, y=7.5)
#Label
mlabel = Label(app, text='')
mlabel.place(x=5, y=35)
mlabel1 = Label(app, text='')
mlabel1.place(x=5, y=65)
mlabel2 = Label(app, text='')
mlabel2.place(x=5, y=95)
#More Labels
nlabel = Label(app, text= 'Opposite side')
nlabel.place(x=65, y=7.5)
nlabel1 = Label(app, text= 'Hypotenuse')
nlabel1.place(x=65, y=57.5)
nlabel2 = Label(app, text= 'Adjacent side')
nlabel2.place(x=65, y=107.5)
#Entry
opp = Entry(textvariable=ment).place(x=150, y=7.5)
hyp = Entry(textvariable=ment1).place(x=150, y=57.5)
adj = Entry(textvariable=ment2).place(x=150, y=107.5)


app.mainloop()
 
Copyright © 2010 M(ath)+me, All rights reserved