How to run PyOS_InputHook from python code (i.e. yield to event loops)

ville ville at ville-desktop.i-did-not-set--mail-host-address--so-tickle-me
Sat Sep 13 15:41:37 CEST 2008


Sean DiZazzo <half.italian at gmail.com> writes:


>> My eventual code would be something like:
>>
>> launch_process_in_thread('bzr pull')
>>
>> while not is_done:
>>   pyos_inputhook()
>>   time.sleep(0.1)
>>
>> print "Done!"
>
> I'm still recovering from a hangover, so don't quote me.  I think you
> want the "after" function:
>
> launch_process_in_thread('bzr pull')
> self.update()
>
> def update(self):
>     while not self.is_done:
>         self.after(2000, self.update)

That's tk-specific, right? I'm looking for a snippet that

- Would not be tied to tk

- Would run sequentially, i.e. the next command would not be entered
  before the process has finished. Just like os.system()







More information about the Python-list mailing list