[pygtk] Unresponsive Window with commands.getstatusoutput

Steve McClure sMcClure at racemi.com
Thu Nov 9 05:37:18 WST 2006


On Wed, 2006-11-08 at 19:34 +0000, Christopher Bland wrote:
> I've read a bunch of threads and such online but I'm having a hard time
> wrapping my brain around this one...
> 
> I have an app that makes a call to commands.getstatusoutput(...) and
> the system call (dd to image a drive) takes a LONG time. Obviously this
> is blocking any/all GTK calls and the window never gets refreshed so
> the user things that the app froze and then closes it.
> 
> I have a progress bar which I set to pulse during this operation so the
> user gets some warm-fuzzy that it is working but that obviously doesn't
> work.
> 
> Has anyone done anything similar to this and gotten the window to be
> semi-responsive? I've been working on this for a few weeks and it's
> killing me. Any input would be much appreciated. Thanks!

I've used threads for all of these situations. The thread would execute
the long running program letting the "main thread" process the event
loop.

> 
> Here are some lines in from my code (I am not using threading either):
> 
> mygui.py
> import moreCode
> 
> def progress_time out(pbobj):
>     # increment the progress bar and do some other things
>     return True
> 
> class MyGUI:
>     def __init__(self):
>         # all of my initialization code to get the GUI up
>         self.timer = gobject.timeout_add(100, progress_timeout, self)
>         self.window.show_all()
> 
>     def main(self):
>         gtk.main()
> 
>     def startWork(self, widget, data=None):
>         # This gets called when the user clicks a 'Start' button
>         moreCode.doStuffNow()
> 
> if __name__ == '__main__':
>     gui = MyGUI()
>     gui.main()
> 
> moreCode.py
> import commands
> def doStuffNow:
>     # This is where the bulk of my processing is done
>     # including the call to image my drive.
>     out = commands.getstatusoutput('dd if=/dev/abc
> of=/my/path/image.bin, conv=notrunc,noerror,sync')
>     return
> 
> 
> 
> ________________________________________________________________________
> Try Juno Platinum for Free! Then, only $9.95/month!
> Unlimited Internet Access with 1GB of Email Storage.
> Visit http://www.juno.com/value to sign up today!
> 
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Steve McClure                                     Racemi
email: smcclure at racemi.com                        380 Interstate North Pkwy, SE
voice: 404-892-5850                               Suite 250
fax: 404-892-7215                                 Atlanta, GA 30339
                                                  http://www.racemi.com



More information about the pygtk mailing list