How to run a python app in the background?

Steve Holden steve at holdenweb.com
Thu Nov 20 22:36:47 EST 2008


Aaron Brady wrote:
> On Nov 20, 6:13 pm, kevint... at gmail.com wrote:
>> 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.

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
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list