-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:

Error: AttributeError: 'NoneType' object has no attribute 'current'. Please help.

Abhishek Bhatia
  • 9,404
  • 26
  • 87
  • 142

1 Answers1

2

At the moment you call:

print self,self.parent.current

the LoginScreen is not instantiated yet, so you are calling for and object that does not exist.

The workaround is to delay the call by 1 frame, that can be done using Clock class:

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

and latter in your code but in the same class:

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

Hope it helps.

Andrei Sima
  • 159
  • 1
  • 11