Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (120 points)
# import tkinter as tk

import tkinter as tk

from tkinter import messagebox

#Save function

def save():

    entno = int(ent1.get())

    no1 = int(ent2.get())

    no2 = int(ent3.get())

    

    

#Location

    file = open("C:\\Users\\shiva\\OneDrive\\Desktop\\PYTHON",'a')

#Message Box    

    if entno == 1:

        messagebox.showinfo(title='Solution',message=('Answer is ', no1+no2))

    elif entno == 2:

        messagebox.showinfo(title='ERROR',message='Answer is',no1-no2)

    elif entno==3:

        messagebox.showinfo(title='ANS',message=no1*no2)    

    else:

        messagebox.showinfo(title='ANS',message=no1/no2)

    

#GUI    

screen = tk.Tk() # screen

screen.title('Calculator')#for title

screen.geometry('1000x900') # for dimensions

screen.configure(bg = '#000000') #

#HEADING

lab1 = tk.Label(screen,text='Press 1 for Add\n Press 2 for Sub\n Press 3 for Mult\n Press 4 for Div',font= (

'times new roman',20))#creation

#lab1.place(x=200,y=200)

#lab1.grid(row=0,column=0)

lab1.place(x=400,y=150)

#ENTER NUMBER

lab2 = tk.Label(screen,text = 'Enter',font= ('times new roman',16))

lab2.place(x=340,y=300)

ent1 = tk.Entry(screen,font= ('times new roman',16))

ent1.place(x=400,y=300)

#1st NUMBER

lab3 = tk.Label(screen,text = 'Enter your FIRST number',font= ('times new roman',16))

lab3.place(x=170,y=350)

ent2 = tk.Entry(screen,font= ('times new roman',16))

ent2.place(x=400,y=350)

#2nd NUMBER

lab4 = tk.Label(screen,text = 'Enter yur SECOND number',font= ('times new roman',16))

lab4.place(x=155,y=400)

ent3 = tk.Entry(screen,font= ('times new roman',16))

ent3.place(x=400,y=400)

but1 = tk.Button(screen,text='Submit',font= ('times new roman',20),command = save)

but1.place(x=450,y=500)

                                            

screen.mainloop()
Please log in to answer this question.

Related questions

0 votes
0 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...