Answered step by step
Verified Expert Solution
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 initself:
printTitle: Calculator Application"
printDescription: This project uses the tkinter library to create a basic calculator"
def displaynameself:
printWe are:"
for i in Meshari Alnafie", "Khaild Alodaib", "Dhaifallah Alshammari", "Misfer Almukhales":
printi
printGMDMohamed Amin"
def guiself:
root.geometryx
root.titleCalculator
# Frame cover page
frame Framemasterroot, width height bg#edd
frame.pack
# Label as title
Apptitle Labelmasterroot, text"Calculator Application", fontGill Sans', 'bold'
padx pady bg#ccbdbd
Apptitle.placex y
# num
num Labelmasterroot, text"number bg#baeae"
numplacex y
# num
num Labelmasterroot, text"number bg#baeae"
numplacex y
# Inputs for two numbers
numinput Entrymasterroot
numinput.placex y
numinput Entrymasterroot
numinput.placex y
# Operator is
operatoris Labelmasterroot, text"operator is: bg#baeae"
operatorisplacex y
operatorinput Entrymasterroot, width
operatorinput.placex y
# Output button & function
def calcfunction:
n intnuminput.get
n intnuminput.get
operator stroperatorinput.get
global x
if operator :
x n n
elif operator :
x n n
elif operator :
x n n
elif operator :
x n n
elif operator :
x math.pown n
else:
x "invalid operator"
# Result label
result Labelmasterroot, textx fontGulim 'italic'
result.placex y
output Buttonmasterroot, text"calc", bg#baeae", foreground"red", commandcalcfunction
output.placex y
def endfunction:
root.destroy
endbtn Buttonmasterroot, text"end", bg#baeae", foreground"red", commandendfunction
endbtn.placex y
root.configbg#acf pady
root.mainloop
# Object from the class
obj CalculatorClass
objdisplayname
objgui
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started