0

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

Sid
  • 61
  • 4
  • 10
  • 1
    Share your current code, or we won't be able to help you – Roy Holzem Nov 30 '16 at 10:04
  • 1
    The reload function (built-in function in Python 2, contained in module imp in Python 3) might be what you are looking for – guidot Nov 30 '16 at 10:14
  • Possible duplicate of [How do I unload (reload) a Python module?](http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module) – guidot Nov 30 '16 at 10:22
  • Possible duplicate of [python refresh/reload](http://stackoverflow.com/questions/1517038/python-refresh-reload) – Ari Gold Nov 30 '16 at 10:23

2 Answers2

2

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.

Oliver
  • 21
  • 5
-1

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 ..

shijin
  • 461
  • 4
  • 11