Skip to content
Advertisement

How can I refresh/reinitialize a class with the values gotten from another class?

So the question title pretty much sums it up. I apologise in advance if I have too much information as I don’t know exactly where the problem arises but the issue is in the transition between class StartPage and class PageOne.I basically want to get the text from first_button (I will add more of these later) and grab data from a file which has a name matching to the button text. This data will then be added in the for-loop in PageOne. However, it seems like PageOne is at its initial state despite the function transition()

JavaScript

Advertisement

Answer

You need to move the data adding code to a separate method if you want to call it later. Things that are in the __init__ method are executed when the instance is created, and never again.

JavaScript

Once you have done that you can call that method from another class like this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement