AttributeError: NoneType object has no attribute current

2024/11/24 0:24:19
class LoginScreen(Screen):def __init__(self,**kwargs):super(LoginScreen, self).__init__(**kwargs)print self,self.parent.currentclass 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.

Answer

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 '-'*25print selfprint self.parent# print self.parent.curet <- this will throw you an error print '-'*25

Hope it helps.

https://en.xdnf.cn/q/120599.html

Related Q&A

Python urllib2 or requests post method [duplicate]

This question already has answers here:Submitting to a web form using python(3 answers)Closed 8 years ago.The community reviewed whether to reopen this question 9 months ago and left it closed:Original…

How to fix Django NoReverseMatch Error

I have built a simple blog app with Django and I have had some issue with NoReverseMatch. Here are my problem screenshots: https://prnt.sc/imqx70 https://prnt.sc/imqwptHere is my code on Github: https:…

Selenium NoSuchElementException with driver.find_element_by_xpath

First question: How do I make python minimize chrome? Second question: When getting to the end page using the next button how do I tell python to go on.. and not give me an error?driver.get("htt…

Traverse Non-Binary Tree [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 9 years ago.Improve…

Muscle alignment in python

I have a problem with printing my output from muscle aligning in python. My code is:from Bio.Align.Applications import MuscleCommandline from StringIO import StringIO from Bio import AlignIOdef align_v…

why does my function is returning data type None??: Python datatype None

This is my python code for printing an absolute number. My function is returning type None. I am not getting what I have done wrong. Please help me. def n(num):if num<0:return (num*-1)no = input(&qu…

np.sum Not returning total counts

I am trying this code but it does not return total count for zero[x][y], in this case it should return 5 but all it displays 255 five time. THIS CODE IS FOR CONNECTED COMPONENTS AND ZERO IS ONE COMPONE…

Python Printing Dictionary Key and Value side by side

I want a program that prints Key and Value side by side for the following code:This is a Dictionary:d = {M: [Name1, Name2, Name3], F: [Name1,Name2,Name3]}I want the a program that prints in the followi…

can i use rusts match in python? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.This question does not appear to be about programming within the scope defined in the help center.Cl…

Consolidating Elements of a List [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 6…