Unsolved Python script not exit
I have this python script. The sys.exit(app.exec()) is not working
To run either :
% ./my.py input
usage my.py [filename] [sourcefile]
% ./my.py input notify.txt
text - This is notify txt file
I ran the script my.py either case, the script didn't exit. I couldn't understand why. I do not want to use "sys.exit()" since this is sort of nested with other script, if you sys.exit() then the process exits.
from PyQt6 import QtWidgets
from PyQt6.QtWidgets import QApplication, QMainWindow
app = QApplication(sys.argv)
main = QtWidgets.QMainWindow()
if len(sys.argv) != 3:
print ("usage my.py [filename] [sourcefile]")
text = ""
name = sys.argv
fd = open(sys.argv)
text = fd.read()
print ("text - ", text)
Since you are not showing any widgets, how are you stopping that script ?
Based on its content, there's no need for anything Qt in that script.
I have widgets created after reading the text, but just to make it simple discard those. just testing the sys.ext(app.exe()) which is not working.
How are you calling and how are you trying to exit it ?
in mytest perl script, I have the following:
$cmd = "my.py filename textfile";
if len(sys.argv) != 3: print ("usage my.py [filename] [sourcefile]") sys.exit(app.exec())
If you want to exec this script here, then why are you starting Qt event loop calling app.exec()?! app.exec() is a blocking call and does NOT return until Qt event loop is terminated. There is absolutely no need to start Qt event loop if you want to exit the script...