from
Tkinter
import
*
import
math
class
AppAkademik:
def
__init__(
self
, parent, title):
self
.parent
=
parent
self
.parent.title(title)
self
.parent.protocol(
"WM_DELETE_WINDOW"
,
self
.onKeluar)
self
.aturKomponen()
self
.entP2.focus_set()
def
aturKomponen(
self
):
mainFrame
=
Frame(
self
.parent, bd
=
10
)
mainFrame.pack(fill
=
BOTH, expand
=
YES)
Label(mainFrame, text
=
"Aplikasi Akademik"
).grid(
row
=
0
, column
=
0
, columnspan
=
2
)
Label(mainFrame, text
=
"================="
, fg
=
"red"
).grid(row
=
1
, column
=
0
,
pady
=
10
, columnspan
=
2
)
Label(mainFrame, text
=
"Absensi :"
).grid(
row
=
2
, column
=
0
, sticky
=
W)
self
.entP2
=
Entry(mainFrame, width
=
5
)
self
.entP2.grid(row
=
2
, column
=
1
, sticky
=
W)
Label(mainFrame, text
=
"Tugas :"
).grid(
row
=
3
, column
=
0
, sticky
=
W)
self
.entP1
=
Entry(mainFrame, width
=
5
)
self
.entP1.grid(row
=
3
, column
=
1
, sticky
=
W)
Label(mainFrame, text
=
"Midtest :"
).grid(
row
=
4
, column
=
0
, sticky
=
W)
self
.entP0
=
Entry(mainFrame, width
=
5
)
self
.entP0.grid(row
=
4
, column
=
1
, sticky
=
W)
Label(mainFrame, text
=
"Final :"
).grid(
row
=
5
, column
=
0
, sticky
=
W)
self
.entP3
=
Entry(mainFrame, width
=
5
)
self
.entP3.grid(row
=
5
, column
=
1
, sticky
=
W)
self
.btnCariAkar
=
Button(mainFrame, text
=
"Hitung"
,
command
=
self
.onCariAkar)
self
.btnCariAkar.grid(row
=
6
, column
=
0
, columnspan
=
2
, pady
=
10
)
Label(mainFrame, text
=
"Nilai Angka:"
).grid(
row
=
7
, column
=
0
, sticky
=
W)
self
.entX1
=
Entry(mainFrame)
self
.entX1.grid(row
=
7
, column
=
1
, sticky
=
W)
Label(mainFrame, text
=
"Nilai Huruf:"
).grid(
row
=
8
, column
=
0
, sticky
=
W)
self
.entX2
=
Entry(mainFrame)
self
.entX2.grid(row
=
8
, column
=
1
, sticky
=
W)
def
onCariAkar(
self
, event
=
None
):
A
=
float
(
self
.entP2.get())
B
=
float
(
self
.entP1.get())
C
=
float
(
self
.entP0.get())
D
=
float
(
self
.entP3.get())
self
.entX1.delete(
0
, END)
self
.entX2.delete(
0
, END)
dua_A
=
4
disk
=
A
+
B
+
C
+
D
akar1
=
(disk)
/
dua_A
self
.entX1.insert(END,
str
(akar1))
if
akar1 >
=
80
:
akar2
=
"A"
self
.entX2.insert(END,
str
(akar2))
elif
akar1 >
=
70
:
akar2
=
"B"
self
.entX2.insert(END,
str
(akar2))
elif
akar1 >
=
60
:
akar2
=
"C"
self
.entX2.insert(END,
str
(akar2))
elif
akar1 >
=
40
:
akar2
=
"D"
self
.entX2.insert(END,
str
(akar2))
else
:
akar2
=
"E"
self
.entX2.insert(END,
str
(akar2))
def
onKeluar(
self
, event
=
None
):
self
.parent.destroy()
if
__name__
=
=
'__main__'
:
root
=
Tk()
aplikasi
=
AppAkademik(root,
"Aplikasi Akasemik"
)
root.mainloop()