Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从一个类到另一个类的kivy变量_Python_Class_Kivy - Fatal编程技术网

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
的实例–它可以在构造函数中传递。或者两者都应该具有由其他内容确定的相同参数–然后该参数应该传递给两个构造函数。没有任何上下文就很难知道。你可以从中使用答案。