How to run a python app in the background?

K

kevintylr

I'm a beginning programmer writing a tiny app with a TkInter GUI.
Desired functionality:
When the user enters a time interval, I want the windows to disappear,
and the program to lie dormant until the scheduled time (currently
using sched module), when it would pop up another window and execute a
command.

Current functionality:
When the user clicks through a showinfo() window, root.quit() is
executed. As I understand it, the program will then complete the
commands that come after root.mainloop(), where I have put
schedule.entry(...) and schedule.run().
The problem is that the windows just hang until the schedule event
happens. The schedule is using time.sleep as the delay. And I have no
idea how I'd create a notification popup when the command runs.

Is there any obvious solution to this problem? Or a tricky solution?
Should I put the scheduler before root.mainloop()? Can I still kill
the main window if I do that?
I want the app to be totally silent during the interim period.

Thanks for your help
Kevin
 
A

Aaron Brady

I'm a beginning programmer writing a tiny app with a TkInter GUI.
Desired functionality:
When the user enters a time interval, I want the windows to disappear,
and the program to lie dormant until the scheduled time (currently
using sched module), when it would pop up another window and execute a
command.

Current functionality:
When the user clicks through a showinfo() window, root.quit() is
executed. As I understand it, the program will then complete the
commands that come after root.mainloop(), where I have put
schedule.entry(...) and schedule.run().
The problem is that the windows just hang until the schedule event
happens. The schedule is using time.sleep as the delay. And I have no
idea how I'd create a notification popup when the command runs.

Is there any obvious solution to this problem? Or a tricky solution?
Should I put the scheduler before root.mainloop()? Can I still kill
the main window if I do that?
I want the app to be totally silent during the interim period.

Thanks for your help
Kevin

Just guessing. Try 'delete root' after 'root.mainloop()', to see if
you can get it to clean up its resources. Otherwise, subprocesses
might be what you want.
 
S

Steve Holden

Aaron said:
Just guessing. Try 'delete root' after 'root.mainloop()', to see if
you can get it to clean up its resources. Otherwise, subprocesses
might be what you want.

That would be

del root

However it's somewhat unusual (though not unheard of) to call a window's
mainloop method. A more usual structure calls mainloop() as a function.

If your window isn't disappearing after its mainloop() method
terminates, try calling its destroy() method. That ought to get rid of
it! i.e.

root.destroy()

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top