I'm new to Python and are trying to do a small program in which the GUI-window is supposed to re-open while clicking the button.
I read online that the line of code
os.execl(sys.executable, sys.executable, *sys.argv)
is supposed to make your program restart, but all it does is exit the GUI-window and restart Shell totally clean.
from tkinter import *
import sys
import os
def restart_program():
os.execl(sys.executable, sys.executable, *sys.argv)
window = Tk()
window.title("Test")
button = Button(window, text="RESTART", width=6, command=restart_program).grid(row=5, column=0)
window.mainloop()
This is the relevant part of my code atm (I didn't include all the code - some more widgets are adding to the existing, but it's not relevant to the problem). Is there any way to re-open the window called "Test", especially without having to put it in a function? Would be very thankful for help! :)))