Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need explanation for next code import math from tkinter import * from tkinter import ttk from tkinter import messagebox root = Tk ( )

I need explanation for next code
import math
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
root = Tk()
class CalculatorClass:
def _init_(self):
print("Title: Calculator Application")
print("Description: This project uses the tkinter library to create a basic calculator")
def display_name(self):
print("We are:")
for i in ["Meshari Alnafie", "Khaild Alodaib", "Dhaifallah Alshammari", "Misfer Almukhales"]:
print(i)
print("GM04-D.Mohamed Amin")
def gui(self):
root.geometry('600x600')
root.title('Calculator')
# Frame cover page
frame = Frame(master=root, width=600, height=600, bg="#e7d6d6")
frame.pack()
# Label as title
Apptitle = Label(master=root, text="Calculator Application", font=('Gill Sans', 23, 'bold'),
padx=20, pady=10, bg="#ccbdbd")
Apptitle.place(x=50, y=20)
# num1
num1= Label(master=root, text="number1", bg="#b9aeae")
num1.place(x=100, y=100)
# num2
num2= Label(master=root, text="number2", bg="#b9aeae")
num2.place(x=100, y=150)
# Inputs for two numbers
num1_input = Entry(master=root)
num1_input.place(x=188, y=100)
num2_input = Entry(master=root)
num2_input.place(x=188, y=150)
# Operator is
operator_is = Label(master=root, text="operator is:", bg="#b9aeae")
operator_is.place(x=195, y=200)
operator_input = Entry(master=root, width=2)
operator_input.place(x=280, y=198)
# Output button & function
def calc_function():
n1= int(num1_input.get())
n2= int(num2_input.get())
operator = str(operator_input.get())
global x
if operator =="+":
x = n1+ n2
elif operator =="-":
x = n1- n2
elif operator =="*":
x = n1* n2
elif operator =="/":
x = n1/ n2
elif operator =="**":
x = math.pow(n1, n2)
else:
x = "invalid operator"
# Result label
result = Label(master=root, text=x, font=('Gulim',15, 'italic'))
result.place(x=220, y=290)
output = Button(master=root, text="calc", bg="#b9aeae", foreground="red", command=calc_function)
output.place(x=220, y=250)
def end_function():
root.destroy()
endbtn = Button(master=root, text="end", bg="#b9aeae", foreground="red", command=end_function)
endbtn.place(x=220, y=350)
root.config(bg="#a0c2f2", pady=100)
root.mainloop()
# Object from the class
obj1= CalculatorClass()
obj1.display_name()
obj1.gui()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Compare the advantages and disadvantages of external recruitment.

Answered: 1 week ago

Question

Describe the typical steps in the selection process.

Answered: 1 week ago