GUIs and Matplotlib

With this project I was experimenting with the use of Tkinter with Python in order to create a Graphical User Interface. The program itself is only a quadratic equation solver but with the use of a GUI and the library 'Matplotlib' to plot the function, the process for finding the roots of the quadratic equation becomes much simpler for the user.

import math from tkinter import * from tkinter import messagebox import numpy as np import matplotlib.pyplot as plt def operation(): mA=ment.get() mB=ment2.get() mC=ment3.get() bsquared=math.pow(mB,2) discriminant=math.sqrt((bsquared)-4*mA*mC) if discriminant <0: messagebox.showerror(title="Error", message="Value of discriminant is negative") x1=((mB*-1)+discriminant)/(2*mA) x2=((mB*-1)-discriminant)/(2*mA) x1Label=Label(mGui,text=x1,font='Arial 30 bold').place(x=80,y=150) x2Label=Label(mGui,text=x2,font='Arial 30 bold').place(x=240,y=150) print(mA) print(mB) print(mC) print('(x =',x1,')') print('(x =',x2,')') a=[] b=[] for x in range(-10,10,1): y=(mA*x**2+mB*x+mC) a.append(x) b.append(y) fig= plt.figure() plt.grid(True) axes=fig.add_subplot(111) axes.plot(a,b) plt.show() mGui=Tk() mGui.resizable(width=FALSE, height=FALSE) ment=IntVar() ment2=IntVar() ment3=IntVar() mGui.geometry('500x210') mGui.title("Anant's Quadratic Equation solver") mLabel=Label(mGui,text="Quadratic equations are expressed in the form: ax^2+bx+c=0",font="Arial 10 bold").place(x=10,y=7) mLabelA=Label(mGui,text="Enter the value of a:",font= 'Arial 20').place(x=10,y=30) mLabelB=Label(mGui,text="Enter the value of b:",font= 'Arial 20').place(x=10,y=70) mLabelC=Label(mGui,text="Enter the value of c:",font= 'Arial 20').place(x=10,y=110) mEntryA=Entry(mGui,textvariable=ment).place(x=260,y=42) mEntryB=Entry(mGui,textvariable=ment2).place(x=260,y=82) mEntryC=Entry(mGui,textvariable=ment3).place(x=260,y=122) mButton=Button(mGui,text="Ok",command=operation).place(x=400,y=116) xequals=Label(mGui,text="x =",font='Arial 30 bold').place(x=10,y=150) xor=Label(mGui,text='or',font='Arial 30 bold').place(x=175,y=150)