我正在尝试在计算中使用点击事件的值。每当我尝试将其转换为 int 时,它都会引发此错误:
TypeError: unsupported operand type(s) for -: 'int' and 'main'
这是一段得到错误的代码
def goto(self, event):
self.ex = int(event.x)
self.ey = int(event.y)
self.find_distance(self.ex, self.ey)
def find_distance(xclick, yclick, self):
#distance formula = sqrt((x2 - x1)^2 + (y2 - y1)^2)
self.xadd = (xPos - xclick)^2
self.yadd = (yPos - yclick)^2
self.step2 = self.xadd + self.yadd
print sqrt(step2)