Skip to main content

My first Python Project Experience .

My first python project is to make a basic Calculator.
This project is very precious project for me because i take one month to make and prepare this project.I and my group members does hardwork to complete this project.
here is the coding of this programe which i have made with the help of my team mates :

from tkinter import*
import random
import time;
import datetime
root=Tk()
root.geometry("450x650+0+0")
root.title("calculator")
#===================================(Functions,variables N operators)=============================
text_input=StringVar()
operator=""
def btnClearDisplay():
    global operator
    operator=""
    text_input.set("")
def btnEqualsInput():
    global operator
    sumup=str(eval(operator))
    text_input.set(sumup)
    operator=""
def btnClick(numbers):
    global operator
    operator=operator+str(numbers)
    text_input.set(operator)
#====================================(Frame and label)====================================
Tops=Frame(root,width=450,height=100,bd=8,relief="raise")
Tops.pack(side=TOP)
f1=Frame(root,width=450,height=550,bd=8,relief="raise")
f1.pack(side=LEFT)
#====================================(Label N Display Area)====================================
lblinfo=Label(Tops,font=('arial',24,'bold'),text="Shekhar's Calculator",fg="orange",bg="cyan",bd=10,anchor="w")
lblinfo.grid(row=0,column=0)
txtDisplay=Entry(f1,font=('arial',20,'bold'),textvariable=text_input,bd=40,insertwidth=5, justify='right')
txtDisplay.grid(columnspan=4)

#================================================================================
#=================================(9,8,7,+)=========================================
#================================================================================
btn7=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='7',command=lambda:btnClick(7)).grid(row=1,column=0)
btn8=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='8',command=lambda:btnClick(8)).grid(row=1,column=1)
btn9=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='9',command=lambda:btnClick(9)).grid(row=1,column=2)
btnPlus=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='+',command=lambda:btnClick("+")).grid(row=1,column=3)
#================================================================================
#=================================(4,5,6,-)=========================================
#================================================================================
btn4=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='4',command=lambda:btnClick(4)).grid(row=2,column=0)
btn5=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='5',command=lambda:btnClick(5)).grid(row=2,column=1)
btn6=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='6',command=lambda:btnClick(7)).grid(row=2,column=2)
btnMinus=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='-',command=lambda:btnClick("-")).grid(row=2,column=3)
#================================================================================
#=====================================(1,2,3,*)====================================
#================================================================================
btn1=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='1',command=lambda:btnClick(1)).grid(row=3,column=0)
btn2=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='2',command=lambda:btnClick(2)).grid(row=3,column=1)
btn3=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='3',command=lambda:btnClick(3)).grid(row=3,column=2)
btnMultiply=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='*',command=lambda:btnClick("*")).grid(row=3,column=3)
#================================================================================
#================================(0,cls,=,/)=========================================
#================================================================================
btn0=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='0',command=lambda:btnClick(0)).grid(row=4,column=0)
btnClear=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='C',command=btnClearDisplay).grid(row=4,column=1)
btnEqualto=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='=',command=btnEqualsInput).grid(row=4,column=2)
btnDivide=Button(f1,padx=16,pady=16,bd=8,fg='black',font=('arial',20,'bold'),text='/',command=lambda:btnClick("/")).grid(row=4,column=3)
root.mainloop()









Comments

Popular posts from this blog

How to download and install MySQL for windows.

Here I am going to show you that how to download and install MySQL first go to MySQL official link to download it :  https://dev.mysql.com/downloads/ you can get a option of MySQL installer for Windows : as your own choice you can download the setup if you want to download online installation then you can download web for online installation one or you can also download the the offline installer I suggest you to download second setup . After downloading you can run the setup and adjust the installation setting according to your need. Here are the steps to successfully install mysql in your system for windows: So here we go: Step 1:Run the setup of Mysql then you will able to view this first page of the setup. you dont have to change the option to another option you have to choose only Developer Default option. Step 2: Then after clicking next button you will able to see a new window name as check Requirements .then you have to click on execute button. Step 3:In this ...