I have 2 files, one.py and two.py, one.py is my main file which i want to run to start my program, I want to access a variable from the GUI class from one.py into another file, without creating an object of that class, as that would create another window
Is this possible?
If so, can i modify the variable and then send it back to one.py
File one.py:
import tkinter
class GUI(tkinter.Tk):
def __init__(self):
super().__init__()
self.var = 'value'
self.mainloop()
if __name__ == '__main__':
app = GUI()
File two.py:
from one import GUI
print(GUI().var) #this creates another window, i dont want that
varinside class. OR keep it as class variable, not instance variable.os.system(f"python two.py {app.var}")and in second file usesys.argvto get it. OR if you importtwoin first file then you should runtwo.somefunction(app.var)without importingonein second file`