1

I want to transfer the variable Overall from ScreenOne to ScreenTwo. Is that possible?

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
zeeMonkeez
  • 5,057
  • 3
  • 33
  • 56
  • `Overall` is an instance attribute. You need instances of `ScreenOne` and `ScreenTwo`. Your instance of `ScreenTwo` would have to know about the instance of `ScreenOne` – it could be passed in the constructor. Or both should have the same parameter determined by something else – then that parameter should be passed to both constructors. Hard to know without any context. – zeeMonkeez Mar 17 '16 at 02:40
  • You can use an answer from this [question](http://stackoverflow.com/a/35996077/5994041). – Peter Badida Mar 17 '16 at 07:43

0 Answers0