Final Paper - Muhali
Final Paper - Muhali
[3] http://courses.washington.edu/css450/2010.Fall/InterestingFinalProjects.html
Student Signature______
16 th June 2017
2
()
Teacher Signature_____
16 th June 2017
3
Content
() ....................................................1
Content ............................................................................4
References ...................................................................................13
4
This application is same as like a calculator application in the phone or
computer application. But, in this case we will build this application using python
programming. This application is mainly used for computer Windows XP or above
version of the use of user, this curriculum design is generally the realization of Mini
calculator of python. The application consists of some function that can calculate two
number, the first number and the second number. Its depend on what function that we
want to do. There are add, minus, multiply, divide, and equal. It will show us the result
of the operation.
This application built use python GUI with Tkinter Module. So, it will show the
special interface as calculator usual. It will use Tkinter module and the other component
of it, such as button, entry, label, listbox, and frame. To set the layout we use grid
structure. The goal is to have a result of the calculate operation.
5
# Mini Calculator Using Python GUI
# Calculator.py
# to import module
from Tkinter import *
def points():
global bil1
global bil2
getv = masukan.get()
if "." not in getv:
masukan.delete(0, END)
masukan.insert(0, getv + ".")
if getv == bil1:
bil1 = getv + "."
else:
bil2 = getv + "."
def input_field(x):
global bil1
global bil2
global operator
global hasil
if operator == "nihil" and hasil == "kosong":
get_value = masukan.get()
masukan.delete(0, END)
masukan.insert(0, get_value + x)
6
bil1 = get_value + x
elif operator != "nihil" and hasil == "kosong":
get_value = masukan.get()
if get_value == bil1:
masukan.delete(0, END)
masukan.insert(0, x)
bil2 = x
else:
masukan.delete(0, END)
masukan.insert(0, get_value + x)
bil2 = get_value + x
elif operator == "nihil" and hasil != "kosong" and bil1 != "0":
getv = masukan.get()
if "." in getv:
masukan.delete(0, END)
masukan.insert(0, getv + x)
bil1 = getv + x
else:
masukan.delete(0, END)
masukan.insert(0, x)
bil1 = x
hasil = "kosong"
elif operator != "nihil" and hasil != "kosong":
g = masukan.get()
if g == bil1:
masukan.delete(0, END)
masukan.insert(0, x)
bil2 = x
else:
masukan.delete(0, END)
masukan.insert(0, g + x)
bil2 = g + x
def clear():
global bil1
global bil2
global operator
global hasil
7
masukan.delete(0, END)
bil1 = "0"
bil2 = "0"
operator = "nihil"
hasil = "kosong"
def set_operator(x):
global operator
if operator == "nihil":
operator = x
else:
eksekusi()
operator = x
def eksekusi():
global bil1
global bil2
global operator
global hasil
if operator != "nihil":
if operator == "/" and bil2 == "0":
masukan.delete(0, END)
masukan.insert(0, "Error!")
hasilnya = "susah"
bil1 = hasilnya
else:
exec ("hasilnya = %s %s %s" % (bil1, operator, bil2))
masukan.delete(0, END)
masukan.insert(0, hasilnya)
bil1 = "%i" % hasilnya
else:
hasilnya = bil1
bil1 = hasilnya
bil2 = "0"
operator = "nihil"
8
def bilbul():
global bil1
global bil2
global opertor
getv = masukan.get()
if getv == bil1:
masukan.delete(0, END)
exec ("res = %s * -1" % getv)
masukan.insert(0, res)
bil1 = "%i" % res
else:
masukan.delete(0, END)
exec ("res = %s * -1" % getv)
masukan.insert(0, res)
bil2 = "%i" % res
root = Tk()
root.title("Mini Calculator Using Python") # give the title of the
frame application
mainloop()
11
The application consists of some function that can calculate two number, the
first number and the second number. Its depend on what function that we want to do.
There are add, minus, multiply, divide, and equal. It will show us the result of the
operation.
We have number 0 until 9, the button for add, minus, multiply, devide, and the equal. We
also have the point button, minus/plus number button and also the clear button to recalculate
the number. In the top of the application we have text field that can use to show the number
tha we click and also show the result of the opertation.
12
13
References
[1] Hetland, Magnus Lie. Beginning Python from Novice to Professional, Second
Edition. New York: Apress and Springer-Verlag Inc, 2008.
[3] http://courses.washington.edu/css450/2010.Fall/InterestingFinalProjects.html
14