Reputation: 91
So I'm trying to display two numbers using the same .bind ("):
def distance(event):
dchain.configure(text = "distance = " + str(sqrt((x1-z1)**2 + (y1-v1)**2) - 30))
def gravitationalForce(event):
fchain.configure(text = "force = " + str(pow(6.6710, -11.0)*(m1*m2/pow((sqrt((x1-z1)**2 + (y1-v1)**2) - 30), 2))))
win1=Tk()
win1.bind("<ButtonPress>", distance)
win1.bind("<ButtonPress>", gravitationalForce)
dchain = Label( win1)
dchain.grid(row=10, column=1, sticky=W)
fchain = Label( win1)
fchain.grid(row=11, column =1, sticky = W)
One seems to cancel the other one out, I tried using a and a this worked but now I'd like to add some more options and would like to know how this works.
Upvotes: 0
Views: 37
Reputation: 49320
Just wrap the functions into one. You can even do it inline with a lambda
expression:
...
win1=Tk()
win1.bind("<ButtonPress>", lambda event: distance(event), gravitationalForce(event))
dchain = Label( win1)
...
Upvotes: 3