Ich habe ein GUI-Programm auf Python 3 und eine file.txt
, die einige Startoptionen enthält. Einer von ihnen ist:Python 3 - Deaktivieren Sie die Anzeige der Konsole
Console (Yes/No) = ...
Die Sache ist, ich will die Konsole angezeigt werden oder nicht, ob es ein „Ja“ oder „Nein“.
fand ich einen Weg, dies zu tun:
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()
es funktioniert Zum Glück, aber wie ich auf Linux arbeiten, und ich möchte teilen mein Programm mit Leuten unter Windows habe ich ein Problem festgestellt: wenn sie starten script1.pyw
alles läuft gut, aber was auch immer sie in file.txt
setzen, die Python-Shell öffnet sich damit (und es ist absolut nicht das, was ich will ...)
Hat jemand eine Idee?
FYI brauchen Sie nicht mit Ihrem eigenen Format für die Konfiguration zu kommen: https://docs.python.org/2/library/configparser.html – jonrsharpe
Mögliche Duplikat [Run Python-Skript ohne Windows-Konsole erscheinen ] (http://stackoverflow.com/questions/1689015/run-python-script-without-windows-console-appearing) – jonrsharpe