Y 20 Width 220 Height 30)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1617460405693763

from Tkinter import *

tk = Tk()

tk.geometry('260x370')

value = StringVar()

value1 = 0.0

valueFinal = StringVar()

operation = StringVar()

ent = Entry(justify=RIGHT font='14' textvariable=value)

ent.place(x=20 y=20 width=220 height=30)

def BC_click():

ent.delete(0 'end')

def B1_click():

ent.insert(END '1')

def B2_click():

ent.insert(END '2')

def B3_click():

ent.insert(END '3')

def B4_click():

ent.insert(END '4')

def B5_click():

ent.insert(END '5')

def B6_click():

ent.insert(END '6')

def B7_click():

ent.insert(END '7')

def B8_click():

ent.insert(END '8')

def B9_click():

ent.insert(END '9')

def Multiply_click():

global value1

1
global operation

value1 = value.get()

operation = 'multiply'

ent.delete(0 'end')

def Divide_click():

global value1

global operation

value1 = value.get()

operation = 'divide'

ent.delete(0 'end')

def Minus_click():

global value1

global operation

value1 = value.get()

operation = 'minus'

ent.delete(0 'end')

def Plus_click():

global value1

global operation

value1 = value.get()

operation = 'plus'

ent.delete(0 'end')

def Point_click():

ent.insert(END '.')

def Equals_click():

global value1

global operation

a = oat(value1)

b = oat(ent.get())

ent.delete(0 'end')

if (operation == 'multiply'):

ent.insert(END a*b)

elif (operation == 'plus'):

2
fl
fl
ent.insert(END a+b)

elif (operation == 'minus'):

ent.insert(END a-b)

else:

ent.insert(END a/b)

BC = Button(text="C" font="14" command=BC_click).place(x=20


y=60 width=100 height=40)

Equals = Button(text="=" font="14" command=Equals_click).place(x=140


y=60 width=100 height=40)

B7 = Button(text="7" font="14" command=B7_click).place(x=20


y=120 width=40 height=40)

B8 = Button(text="8" font="14" command=B8_click).place(x=80


y=120 width=40 height=40)

B9 = Button(text="9" font="14" command=B9_click).place(x=140


y=120 width=40 height=40)

Divide = Button(text="/" font="14" command=Divide_click).place(x=200


y=120 width=40 height=40)

B4 = Button(text="4" font="14" command=B4_click).place(x=20


y=180 width=40 height=40)

B5 = Button(text="5" font="14" command=B5_click).place(x=80


y=180 width=40 height=40)

B6 = Button(text="6" font="14" command=B6_click).place(x=140


y=180 width=40 height=40)

Multiply = Button(text="*" font="14" command=Multiply_click).place(x=200


y=180 width=40 height=40)

B1 = Button(text="1" font="14" command=B1_click).place(x=20


y=240 width=40 height=40)

B2 = Button(text="2" font="14" command=B2_click).place(x=80


y=240 width=40 height=40)

B3 = Button(text="3" font="14" command=B3_click).place(x=140


y=240 width=40 height=40)

Minus = Button(text="-" font="14" command=Minus_click).place(x=200


y=240 width=40 height=40)

B0 = Button(text="0" font="14").place(x=20
y=300 width=100 height=40)

Point = Button(text="." font="14" command=Point_click).place(x=140


y=300 width=40 height=40)

Plus = Button(text="+" font="14" command=Plus_click).place(x=200


y=300 width=40 height=40)

tk.mainloop()

You might also like