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

4
  • 1
    Share your current code, or we won't be able to help you Commented Nov 30, 2016 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 Commented Nov 30, 2016 at 10:14
  • Possible duplicate of How do I unload (reload) a Python module? Commented Nov 30, 2016 at 10:22
  • Possible duplicate of python refresh/reload Commented Nov 30, 2016 at 10:23

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.