[Urwid] run long time command in urwid

Ian Ward ian at excess.org
Tue Nov 23 12:19:06 EST 2010


Naihong Tang wrote on 2010-11-23 03:10:
> Hello,
> 
> I plan to write a RAID building program with urwid. In the first window,
> input some parameters, after user press the OK button, popup a new
> window with progress bar, indicating the finished percentage, and do not
> accept user input in this window, this window will close itself after
> building procedure finished. Since the RAID building procedure will last
> long time, about 10 hours, so it cannot be placed in OnButtonPressed()
> event. After reading the urwid document, I think use thread or subclass
> widget Run() can do this. I would like to know if there is other simple
> way to implement. 

You could use threads, but it might be easier to just poll the status of
the RAID array creation from a MainLoop.set_alarm_in callback.  That way
it's easy to update what's displayed (no synchronization required)

http://excess.org/urwid/reference.html#MainLoop

I'm not sure where you're reading about Run or OnButtonPressed methods,
though..

HTH
Ian



More information about the Urwid mailing list