I want to import a variable from another python file.
This first file runs on the side of file2 on a second window.
File1.py
def onlinecheckext():
global onlinecheckvarr
while 1:
try:
onlinecheckscc = pyautogui.locateOnScreen(imPath("start_detect.png"))
if onlinecheckscc is None:
logging.debug("I am Online")
onlinecheckvarr = True
time.sleep(2)
else:
logging.debug("I am not online")
onlinecheckvarr = False
time.sleep(2)
except:
logging.debug("Online check fail")
return False
File2.py
from file1 import onlinecheckvarr
while onlinecheckvarr is True:
print("TEST")
else:
print("Test2")
Error : NameError: name 'onlinecheckvarr' is not defined.
I have try almost everything and still didn't get it, it's a global var and i imported it right i think but it still throws errors.