I have a GUI program on python 3 and a file.txt
which contains some launch options. One of them is :
Console (Yes/No) = ...
The thing is i want to display or not the console if there is a "Yes" or a "No".
I found a way to do so :
In script1.pyw
:
import os
def getParam():
param = open("file.txt","r").read()
param.split(" = ")[1] # getting the value of "Console = "
return(param)
param = getParam()
if "script2.py" in listdir():
if param == "No":
os.rename("script2.py","script2.pyw")
os.system("python script2.pyw")
elif param == "Yes":
os.system("python script2.py")
if "script2.py" in listdir():
if param == "Yes":
os.rename("script2.pyw","script2.py")
os.system("python script2.py")
elif param == "No":
os.system("python script2.pyw")
In script2.py(w)
:
from tkinter import *
window = tk.Tk()
...
window.mainloop()
Fortunately it works but as I work on Linux and I want to share my program with people on Windows I encountered a problem : when they launch script1.pyw
everything goes well but whatever they put in file.txt
, the python's shell opens with it (and it is absolutely not what I want...)
Do someone have any idea?