2015-09-03 81 views
-4
class LoginScreen(Screen): 
    def __init__(self,**kwargs): 
     super(LoginScreen, self).__init__(**kwargs) 
     print self,self.parent.current 

class AppScreenManager(ScreenManager): 
    pass 

#Base Class 
class AppBaseClass(App): 
    def build(self): 
     icon='app_icon' 
     return Builder.load_file('appbase.kv') 


________________________________________________________________________________________________ 

AppScreenManager: 
    transition: FadeTransition() 
    LoginScreen: 

错误:AttributeError:'NoneType'对象没有属性'current'。请帮忙。AttributeError:'NoneType'对象没有'current'属性

+0

这个错误ocurr在哪里?我没有看到'current'被调用 –

+0

@劳伦斯本森请立即检查。 –

+3

“self.parent”分配在哪里? –

回答

2

此刻您拨打:

print self,self.parent.current 

的LoginScreen还没有实例化,所以您所要求的和不存在的对象。

Clock.schedule_once(self._myprintfunction, 1/60) 

和后者在你的代码,但在同级别:

def _myprintfunction(self, dt): 
     print '-'*25 
     print self 
     print self.parent 
     # print self.parent.curet <- this will throw you an error 
     print '-'*25 

希望它

的解决方法是通过一帧延迟通话,可使用Clock类来完成帮助。