How to create Simple Gui Calculator in python

Hello Friends Me Aapko Aaj Simple Calculator banane ke Bare me batane wala hu Jisse aap Gui Programming Learn kar Sakte Hai.

Simple Gui Calculator in python

Simple Gui Calculator in python

Simple Calculator kese banate hai python me ham ye is post me learn karte hai . agar aap bhi learn karna chahte hai to ye post ko read kre |

Python Me Gui Application ko create karne ke liye pycharm ka use hota hai. agar aapke pass pycharm software nhi hai to pahle aap download karle .

Simple Calculator in python

Example

from tkinter import *
import tkinter
top = tkinter.Tk()


top.geometry('250x250')
top.maxsize(width=250,height=180)
top.minsize(width=250,height=180)
top.title('Calculator')
top.configure(bg='red')

l= Label(top,text='My Calculator',fg='red').grid(row=0,column=1,sticky=W)
l1=Label(top,text='First Number',).grid(row=1,column=0,sticky=W)
l2=Label(top,text='Second Number',).grid(row=2,column=0,sticky=W)
l3=Label(top,text='Opeartor',).grid(row=3,column=0,sticky=W)
l4=Label(top,text='Answer',).grid(row=4,column=0,sticky=W)

E1= Entry(top,bd=5)
E1.grid(row=1,column=1)
E2= Entry(top,bd=5)
E2.grid(row=2,column=1)
E3= Entry(top,bd=5)
E3.grid(row=3,column=1)
E4= Entry(top,bd=5)
E4.grid(row=4,column=1)



def proces():
    number1=Entry.get(E1)
    number2=Entry.get(E2)
    operator=Entry.get(E3)
    number1=int(number1)
    number2=int(number2)
    if operator =="+":
        answer=number1+number2
    if operator =="-":
        answer=number1-number2
    if operator=="*":
        answer=number1*number2
    if operator=="/":
        answer=number1/number2
    Entry.insert(E4,0,answer)
    print(answer)


B=Button(top, text ="Submit",command = proces,bg='yellow').grid(row=5,column=1,)

top.mainloop()

Output

Aap is coding ko use karke aap bhi aapni gui application bana sakte hai .

Leave a Reply

Your e-mail address will not be published. Required fields are marked *