tkinter - How to use .get() within a function. Python -


from tkinter import * import random  def factorer(a,b,c):     while true:         random_a1=random.randint(-10,10)         random_a2=random.randint(-10,10)         random_c1=random.randint(-10,10)         random_c2=random.randint(-10,10)         if random_a1==0 or random_a2 == 0 or random_c1 == 0 or random_c2 == 0:             pass         elif (random_a1*random_c2) + (random_a2*random_c1) == b , random_a1/random_c1 != random_a2/random_c2 , random_a1*random_a2==a , random_c1*random_c2==c:             break     print "y=(%dx+(%d))(%dx+(%d))" % (random_a1,random_c1,random_a2,random_c2)  root = tk() buttonsim1 = button(root, text="convert", command=lambda: factorer(entera.get(),enterb.get(),enterc.get())) buttonsim1.grid(row=2, column=3) entera = entry(root) entera.grid(row=1, column=1) enterb = entry(root) enterb.grid(row=1, column=2) enterc = entry(root) enterc.grid(row=1, column=3)  root.mainloop() 

how can code run, every time click button crashes. works if remove .get() , insert numbers. in advance

you comparing strings ints, need cast a,b , c int:

tkinter.button(root, text="convert", command=lambda: factorer(int(entera.get()),int(enterb.get()),int(enterc.get()))) 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -