Sid
Sid

Reputation: 61

How to reload a Python script

i am very new to python and I wanted to ask how to reload a Python script, like I want to make a button inside an script that says Reload and when you press on it it refreshes the script, so that I do not have to close it and open it again. Is there any way to do this, I need a step by step guide.

Thanks

Upvotes: 0

Views: 1912

Answers (2)

Oliver
Oliver

Reputation: 21

Instead of reloading it could you use a while loop and have a user input rather than a button as python doesn't have any simple GUI like html tags so:

refresh = "refresh"
while(refresh == "refresh"):
    print("code")
    refresh = input("Type refresh to refresh: ")

Apologies for all the edits.

Upvotes: 2

shijin
shijin

Reputation: 461

It's unclear what you mean with "reload", but the normal behavior of Python is that you need to restart the software for it to take a new look on a Python module and reread it. also you cannot add buttons inside a python script ... for that you may need to use HTML or other ..

Upvotes: -1

Related Questions