*****************NAME- ANIKET - I2 -39*********************
Experiment No.11A
Aim: Write python programs to understand GUI designing using Tkinter.
Program Code:
from tkinter import *
window=Tk()
[Link]("Calculator")
[Link]("350x270")
expression=""
def click(item):
global expression
expression=expression+str(item)
[Link](expression)
def equal():
try:
global expression
result=str(eval(expression))
[Link](result)
expression=""
except:
[Link](" ERROR ")
expression=""
def clear():
global expression
[Link]("")
expression=""
equation=StringVar()
expression_field=Entry(window,textvariable=equation,font=('arial',20,'bold'))
expression_field.grid(columnspan=50,ipadx=100,ipady=30)
button1=Button(window,text='7',command=lambda:click(7),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=2,column=0)
button2=Button(window,text='8',command=lambda:click(8),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=2,column=1)
button3=Button(window,text='9',command=lambda:click(9),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=2,column=2)
button4=Button(window,text='+',command=lambda:click("+"),height=2,width=10,act
ivebackground="red",padx=1,pady=1)
[Link](row=2,column=3)
button5=Button(window,text='4',command=lambda:click(4),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=3,column=0)
button6=Button(window,text='5',command=lambda:click(5),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=3,column=1)
button7=Button(window,text='6',command=lambda:click(6),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=3,column=2)
button8=Button(window,text='-',command=lambda:click("-"),height=2,width=10,acti
vebackground="red",padx=1,pady=1)
[Link](row=3,column=3)
button9=Button(window,text='1',command=lambda:click(1),height=2,width=10,activ
ebackground="red",padx=1,pady=1)
[Link](row=4,column=0)
button10=Button(window,text='2',command=lambda:click(2),height=2,width=10,acti
vebackground="red",padx=1,pady=1)
[Link](row=4,column=1)
button11=Button(window,text='3',command=lambda:click(3),height=2,width=10,acti
vebackground="red",padx=1,pady=1)
[Link](row=4,column=2)
button12=Button(window,text='*',command=lambda:click("*"),height=2,width=10,a
ctivebackground="red",padx=1,pady=1)
[Link](row=4,column=3)
button13=Button(window,text='0',command=lambda:click(0),height=2,width=10,acti
vebackground="red",padx=1,pady=1)
[Link](row=5,column=0)
button14=Button(window,text='=',command=lambda:equal(),height=2,width=10,acti
vebackground="red",padx=1,pady=1)
[Link](row=5,column=1)
button15=Button(window,text='Clear',command=lambda:clear(),height=2,width=10,a
ctivebackground="red",padx=1,pady=1)
[Link](row=5,column=2)
button16=Button(window,text='/',command=lambda:click("/"),height=2,width=10,act
ivebackground="red",padx=1,pady=1)
[Link](row=5,column=3)
[Link]()
Input:
Output:
Conclusion: Hence we have successfully executed the given problem
statement.
Lab Outcome: Explain how to design GUI Applications in Python and
evaluate different database operations.