Python 从一个类到另一个类的kivy变量
我想将变量Python 从一个类到另一个类的kivy变量,python,class,kivy,Python,Class,Kivy,我想将变量total从ScreenOne传输到ScreenTwo。可能吗 class ScreenOne(Screen): def __init__(self,**kwargs): super (ScreenOne,self).__init__(**kwargs) x = random.randint(3,3) random_question = Questions[x][0] self.ans = Questions[
total
从ScreenOne
传输到ScreenTwo
。可能吗
class ScreenOne(Screen):
def __init__(self,**kwargs):
super (ScreenOne,self).__init__(**kwargs)
x = random.randint(3,3)
random_question = Questions[x][0]
self.ans = Questions[x][5]
self.Overall = 0
class ScreenTwo(Screen):
def __init__(self,**kwargs):
super (ScreenTwo,self).__init__(**kwargs)
x = random.randint(0,99)
random_question = Questions[x][0]
self.ans = Questions[x][5]
self.Overall = ScreenOne.Overall
总体
是一个实例属性。您需要屏幕一
和屏幕二
的实例。您的ScreenTwo
实例必须知道screentone
的实例–它可以在构造函数中传递。或者两者都应该具有由其他内容确定的相同参数–然后该参数应该传递给两个构造函数。没有任何上下文就很难知道。您可以使用此选项的答案。Overall
是一个实例属性。您需要屏幕一
和屏幕二
的实例。您的ScreenTwo
实例必须知道screentone
的实例–它可以在构造函数中传递。或者两者都应该具有由其他内容确定的相同参数–然后该参数应该传递给两个构造函数。没有任何上下文就很难知道。你可以从中使用答案。