<s> import IECore <EOL> import Gaffer <EOL> import GafferUI <EOL> class PathFilterWidget ( GafferUI . Widget ) : <EOL> def __init__ ( self , topLevelWidget , pathFilter , parenting = None ) : <EOL> GafferUI . Widget . __init__ ( self , topLevelWidget , parenting = parenting ) <EOL> self . __pathFilter = pathFilter <EOL> self . __pathFilterChangedConnection = self . __pathFilter . changedSignal ( ) . connect ( Gaffer . WeakMethod ( self . __pathFilterChanged ) ) <EOL> def pathFilter ( self ) : <EOL> return self . __pathFilter <EOL> def _updateFromPathFilter ( self ) : <EOL> raise NotImplementedError <EOL> def _pathFilterChangedConnection ( self ) : <EOL> return self . __pathFilterChangedConnection <EOL> def __pathFilterChanged ( self , pathFilter ) : <EOL> assert ( pathFilter . isSame ( self . __pathFilter ) ) <EOL> self . _updateFromPathFilter ( ) <EOL> @ classmethod <EOL> def create ( cls , pathFilter ) : <EOL> visible = True <EOL> with IECore . IgnoredExceptions ( KeyError ) : <EOL> visible = pathFilter . userData ( ) [ "<STR_LIT>" ] [ "<STR_LIT>" ] . value <EOL> if not visible : <EOL> return None <EOL> c = pathFilter . __class__ <EOL> while c is not None : <EOL> creator = cls . __typesToCreators . get ( c , None ) <EOL> if creator is not None : <EOL> return creator ( pathFilter ) <EOL> c = c . __bases__ [ <NUM_LIT:0> ] if c . __bases__ else None <EOL> return None <EOL> @ classmethod <EOL> def registerType ( cls , pathFilterClass , widgetCreationFunction ) : <EOL> cls . __typesToCreators [ pathFilterClass ] = widgetCreationFunction <EOL> __typesToCreators = { } <EOL> class BasicPathFilterWidget ( PathFilterWidget ) : <EOL> def __init__ ( self , pathFilter ) : <EOL> self . __checkBox = GafferUI . BoolWidget ( str ( pathFilter ) ) <EOL> PathFilterWidget . __init__ ( self , self . __checkBox , pathFilter ) <EOL> self . __stateChangedConnection = self . __checkBox . stateChangedSignal ( ) . connect ( Gaffer . WeakMethod ( self . __stateChanged ) ) <EOL> self . _updateFromPathFilter ( ) <EOL> def _updateFromPathFilter ( self ) : <EOL> label = str ( self . pathFilter ( ) ) <EOL> with IECore . IgnoredExceptions ( KeyError ) : <EOL> label = self . pathFilter ( ) . userData ( ) [ "<STR_LIT>" ] [ "<STR_LIT:label>" ] . value <EOL> self . __checkBox . setText ( label ) <EOL> invertEnabled = False <EOL> with IECore . IgnoredExceptions ( KeyError ) : <EOL> invertEnabled = self . pathFilter ( ) . userData ( ) [ "<STR_LIT>" ] [ "<STR_LIT>" ] . value <EOL> self . __checkBox . setState ( self . pathFilter ( ) . getEnabled ( ) is not invertEnabled ) <EOL> def __stateChanged ( self , checkBox ) : <EOL> invertEnabled = False <EOL> with IECore . IgnoredExceptions ( KeyError ) : <EOL> invertEnabled = self . pathFilter ( ) . userData ( ) [ "<STR_LIT>" ] [ "<STR_LIT>" ] . value <EOL> self . pathFilter ( ) . setEnabled ( checkBox . getState ( ) is not invertEnabled ) <EOL> PathFilterWidget . registerType ( Gaffer . PathFilter , BasicPathFilterWidget ) </s>
