2015-10-19 36 views
-1

我想使散点平面布局行为如何我希望它,但是当我尝试缩小超过某个点时,我得到错误“RuntimeError:超过最大递归深度调用Python对象”我无法通过试错弄清楚为什么会发生递归,尽管我已经发现了它发生在哪里(它被标记代码)递归错误我找不出

这里是回溯:http://pastebin.com/i2z8SXgc

class Controller(ScatterPlaneLayout): 
    def __init__(self, **kwargs): 
      super(Controller, self).__init__(**kwargs) 

    def on_transform(self, instance, value): 
     win = self.get_parent_window().size 
     this = self.bbox[1] 

     if win[0] > this[0] and win[1] > this[1]: 
      if self.x < 0: 
      self.x = 0 
      if self.y < 0: 
       self.y = 0 
      if this[0] + self.x > win[0]: 
       self.set_right(win[0]) 
      if this[1] + self.y > win[1]: 
       self.set_top(win[1]) 

     else: 
      if self.x > 0: 
       self.x = 0 
      if self.y > 0: 
       self.y = 0 
       #This is the part that causes the error 
      if this[0] + self.x < win[0]: 
       self.x = win[0] - this[0] 
       #end of error 
      if this[1] + self.y < win[1]: 
       self.set_top(win[1]) 
+0

将堆栈跟踪(重复的部分)放入 – AlbertFerras

+0

欢迎使用StackOverflow。请阅读并遵循发布指南,尤其是[MCVE](http://stackoverflow.com/help/mcve)。为我们提供样本输入和输出(包括期望和您在编码尝试中获得的内容)。既然你知道问题出在哪里,如果你告诉我们,这会有所帮助。 – Prune

+0

哎呀我以为我已经把它放在了,现在是这样,问题是,当我试图缩小超过某个点时它崩溃也错误标记在代码 –

回答

0

看起来会导致错误的是代码self.x = win[0] - this[0]调用函数on_transform,传递第一个if和ca一遍又一遍地把自己安顿下来。

可能想检查一下。

+0

哦,我是一个白痴,谢谢你我几个星期来,我一直在这个沟里,看着我自己的代码,我明显地解决了这个问题 –