At the end of my program execution, I want a popup message to appear that has a button which can re-run a program. Obviously, I will have setup a function that the button calls when it is clicked, as such
def restart():
**python command that makes the whole program restart**
Then I would attach this function to the following button:
B1 = ttk.Button(popup, text='Restart program', width=17, command=lambda: restart())
Is there such a command?
Quick note:I found an answer but it doesn't work, here it is:
os.execl(sys.executable, sys.executable, *sys.argv)
mainor similar) in another method that either calls it again or exits, depending on the state of a variable set by the restart popup.def main(): # all code goes here. Then instead ofrestart(), the button can just callmain().lambda: restart()you can just userestartwithout parentheses to achieve the same thing.