0

I have a Python script that counts the number of file in a folder, and if the number of files exceeds 10 then it creates a popup window to ask the user to clean up the folder (I use tkMessageBox).

How can I have the program run in the background so that it consumes only minimal resources? I tried running it as a daemon and as an agent but I couldn't see anything happen (no popup window).

1 Answer 1

1

Daemons, by definition, have no user interfaces. So that won't work.

What you probably want to do is simply run the program normally. Have it check if there are more than N (for you N=10, but let's keep it generic) files in a folder. If so, it should pop up a tkMessageBox warning the user. If not, it should sleep for CHECK_INTERVAL seconds. Anything from 60 seconds to 10 minutes would be a reasonable default, which would not consume many system resources.

You do not mention what platform you're running on, and you're using Tk, so you probably wish to keep this generic. If you had specific platform choices you could use a more platform-native notifier, which most GUI platforms now support (e.g. Windows, Mac, Ubuntu Unity).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.