I have created an application which has only 1 big class that wrap all of functions. The code run smoothly as it should be.
The code can be divided into sections such as: GUI, pure block codes to handle tasks.
I want to seperate the original class into 2 classes, 1 will be the GUI for application and the other is block code that handles tasks.
The problem is that when I do that, 2 classes use the other's instance variables. How can I fix this, please help, thank you.
Example of the original class:
Class App:
def __init__(self):
self.var1 = 'first variable'
self.var3 = 'third variable'
def method1(self):
self.var2 = 'second variable'
print(self.var3)
def method2(self):
print(self.var2)
self.method1()
Here is the example of the 2 new classes (I just split them up and haven't modify anything):
Class GUI:
def __init__(self):
self.var1 = 'first variable'
def method1(self):
self.var2 = 'second variable'
print(self.var3) # <-- var3 is belonged to class Core
Class Core:
def __init__(self):
self.var3 = 'third variable'
def method2(self):
print(self.var2) # <-- var 2 is belonged to class GUI
self.method1() # <-- method1 belonged to class GUI too