<s> import weakref <EOL> import threading <EOL> import IECore <EOL> import GafferUI <EOL> QtCore = GafferUI . _qtImport ( "<STR_LIT>" ) <EOL> class DeferredPathPreview ( GafferUI . PathPreviewWidget ) : <EOL> def __init__ ( self , displayWidget , path ) : <EOL> self . __tabbedContainer = GafferUI . TabbedContainer ( ) <EOL> GafferUI . PathPreviewWidget . __init__ ( self , self . __tabbedContainer , path ) <EOL> self . __tabbedContainer . setTabsVisible ( False ) <EOL> self . __tabbedContainer . append ( GafferUI . BusyWidget ( size = <NUM_LIT> ) ) <EOL> self . __tabbedContainer . append ( displayWidget ) <EOL> self . __tabbedContainer . append ( GafferUI . Spacer ( size = IECore . V2i ( <NUM_LIT:10> ) ) ) <EOL> self . __busyTimer = QtCore . QTimer ( ) <EOL> self . __busyTimer . setSingleShot ( True ) <EOL> self . __busyTimer . timeout . connect ( IECore . curry ( DeferredPathPreview . __displayBusy , weakref . ref ( self ) ) ) <EOL> def _updateFromPath ( self ) : <EOL> if self . isValid ( ) : <EOL> thread = threading . Thread ( target = IECore . curry ( DeferredPathPreview . __load , weakref . ref ( self ) ) ) <EOL> thread . daemon = True <EOL> thread . start ( ) <EOL> self . __busyTimer . start ( <NUM_LIT> ) <EOL> else : <EOL> DeferredPathPreview . __display ( weakref . ref ( self ) , None ) <EOL> def _load ( self ) : <EOL> raise NotImplementedError <EOL> def _deferredUpdate ( self , loaded ) : <EOL> raise NotImplementedError <EOL> @ staticmethod <EOL> def __load ( selfWeakRef ) : <EOL> self = selfWeakRef ( ) <EOL> if self is None : <EOL> return <EOL> o = self . _load ( ) <EOL> GafferUI . EventLoop . executeOnUIThread ( IECore . curry ( DeferredPathPreview . __display , selfWeakRef , o ) ) <EOL> @ staticmethod <EOL> def __display ( selfWeakRef , o ) : <EOL> self = selfWeakRef ( ) <EOL> if self is None : <EOL> return <EOL> self . __busyTimer . stop ( ) <EOL> if o is not None : <EOL> self . _deferredUpdate ( o ) <EOL> self . __tabbedContainer . setCurrent ( self . __tabbedContainer [ <NUM_LIT:1> ] ) <EOL> else : <EOL> self . __tabbedContainer . setCurrent ( self . __tabbedContainer [ <NUM_LIT:2> ] ) <EOL> @ staticmethod <EOL> def __displayBusy ( selfWeakRef ) : <EOL> self = selfWeakRef ( ) <EOL> if self is None : <EOL> return <EOL> self . __tabbedContainer . setCurrent ( self . __tabbedContainer [ <NUM_LIT:0> ] ) </s>
