Calculator
Calculator
from tkinter import Tk, Frame, Label, LEFT, TOP, Button, X, RIGHT, Entry, IntVar,
Checkbutton, Text, WORD, END
from operations import addition, subtraction, division, multiplication, exponent,
rooting, sine, cosine, tangent, logarithem
from os import path
# Make Window
window = Tk()
window.wm_iconbitmap("main.ico")
window.title("MC1323 Calculator V1.1.4")
window.geometry("400x500")
title = Label(
titleFrame,
text="Welcome to MC1323 Calculator",
bg = 'black',
fg = 'white',
font=("Arial", 15)
).pack(side=LEFT)
exitB=Button(
titleFrame,
text='X',
bg='black',
fg='white',
font=("Arial", 15),
command=window.destroy
).pack(side=RIGHT)
titleFrame.pack(fill=X, side=TOP)
# Options
options = Frame()
Label(options,text='Options:', font=('Ariel', 12, 'bold')).pack(side=TOP)
# Select whether to acumulate values eg. result becomes num1
accumulate = IntVar()
Checkbutton(
options,
border=5,
text="Accumulate", # Label displayed near the checkbox
variable=accumulate, # Link the checkbox to the variable
onvalue=1, # Set value to 1 when checked
offvalue=0, # Set value to 0 when unchecked
).pack(side=LEFT)
# Inverse Function
inverse = IntVar()
Checkbutton(
options,
border=5,
text="Inverse Function", # Label displayed near the checkbox
variable=inverse, # Link the checkbox to the variable
onvalue=1, # Set value to 1 when checked
offvalue=0, # Set value to 0 when unchecked
).pack(side=LEFT)
# Result
result = Text(wrap=WORD)
# Add Buttons
addButton('Add',addition, btnFrame)
addButton('Subtract',subtraction,btnFrame)
addButton('Multiply',multiplication,btnFrame)
addButton('Divide',division,btnFrame)
addButton('Exponent',exponent,btnFrame)
addButton('Root',rooting,btnFrame)
addButton('Sine',sine,btnFrame2)
addButton('Cosine',cosine,btnFrame2)
addButton('Tangent',tangent,btnFrame2)
addButton('Logarithm (SecondNumber for log10())',logarithem,btnFrame2)
addButton('F to C',FtoC,btnFrame3)
# Pakc Frames
btnFrame.pack(side=TOP, fill=X)
btnFrame2.pack(side=TOP, fill=X)
btnFrame3.pack(side=TOP, fill=X)