I took my code from Codeskulptor and put it in pycharm. I figured out how to import simplegui
, but when I run the solution and then click a button after inputting necessary stuff I get an error that says
line 16, in click
a=float(inA.get_text())
AttributeError: 'Input' object has no attribute 'get_text'.
Here is the full code:
import simpleguitk as simplegui
a=1
b=1
c=1
d=1
deriv=0
def click():
global a,b,c,d
a=float(inA.get_text())
b=float(inB.get_text())
c=float(inC.get_text())
d=float(inD.get_text())
label1.set_text('Current equation: '+str(a)+"x²+"+str(b)+"x+"+str(c))
deriv= 2.0*a*d + b
label2.set_text('Slope of graph at x='+str(d)+": "+str(deriv))
def draw_handler(canvas):
z =[]
for x in range (-150,150):
y=a*x**2+b*x+c
z.append([(x)+150,(150-(y))])
list(z)
canvas.draw_polyline(z, 1, 'Red')
canvas.draw_line((150,0),(150,700),1,"white")
canvas.draw_line((0,150),(700,150),1,"white")
def donothing():
q=2
frame = simplegui.create_frame('Testing',300,300)#graphx , graph y)
frame.set_draw_handler(draw_handler)
frame.add_button("Click me",click)
inA= frame.add_input("A value",donothing, 30)
inB= frame.add_input("B value",donothing, 30)
inC= frame.add_input("C value",donothing, 30)
inD= frame.add_input("Find Slope at X=",donothing, 30)
label1 = frame.add_label('Current equation: ')
label2 = frame.add_label('Slope at X=')
frame.start()
Is there a different way of getting text in pycharm that I don't know of?
Thanks