In my imported script 'scan.py' I want to refer to a value of a variable created and initialized before in the main script. Here's the code from the main script:
Input = EJ.get()
os.system ('python scan.py')
FileName = str(r"C:\\Users\\Admin\\Documents\\HPython\\WESMFG\\POnumber\\" + Input + ".pdf")
and the relevant code of the scan.py script:
output_file = Input
print("Output file: %s" % output_file)
.
.
.
print("Writing output file ...")
img = scan_session.images[0]
img.save(output_file, "JPEG")
print("Done")
'Input' stores the Input of the Entry widget EJ from my Tkinter GUI. So I want the user to type in something, so this input gets the name of the new scanned document.
When running the main script, it tells me 'Input' is not defined.
Since I'm kind of new to programming on python, maybe I'm falsely ignoring
if __name__ == "__main__":
pyinsane2.init()
try:
main()
finally:
pyinsane2.exit()
at the end of scan.py. Does this matter in any way to my question?
What I have tried:
import __main__
main_global1= __main__.global1
but since 'Input' is in a function it tells me there is no variable in main called 'Input'