I need to restart my application when a button is clicked, but I'm having some problems with it. I've tried two methods:
Tried this suggestion and it indeed restarts the application, but I get a
Gtk_IS_INVISIBLE (widget)
error for every widget, and all of them look different in the restarted application, with a very "old" look (similar to TkInter widgets). Is there a way so solve this error? Besides this, the application works fine.I also tried:
subprocess.Popen("/home/pi/pywork/pyqt/of2.py") sys.exit(0)
as suggested here, but I get the following error:
OSError: [Errno 13] Permission denied
. Is there a way to override this denied permission?
None of them seem to work properly. Is there a way to fix any of them? Do you know an alternative method to restart the application?
You could use QProcess.startDetached:
You also have to properly add the shebang to your python script:
The second method gives an error because the file is not executable. You could fix that, but it is probably more robust to just re-run the script using the same python executable. It would also be a good idea to avoid hard-coding the script path.
Here is a simple demo script that implements all that: