<s> import warnings <EOL> import Gaffer <EOL> import GafferUI <EOL> QtCore = GafferUI . _qtImport ( "<STR_LIT>" ) <EOL> QtGui = GafferUI . _qtImport ( "<STR_LIT>" ) <EOL> class SelectionMenu ( GafferUI . Widget ) : <EOL> __palette = None <EOL> def __init__ ( self , parenting = None ) : <EOL> warnings . warn ( "<STR_LIT>" , DeprecationWarning , <NUM_LIT:2> ) <EOL> GafferUI . Widget . __init__ ( self , QtGui . QComboBox ( ) , parenting = parenting ) <EOL> self . _qtWidget ( ) . currentIndexChanged . connect ( Gaffer . WeakMethod ( self . __changed ) ) <EOL> self . _qtWidget ( ) . activated . connect ( Gaffer . WeakMethod ( self . __selected ) ) <EOL> self . __currentIndexChangedSignal = GafferUI . WidgetSignal ( ) <EOL> self . __selectedSignal = GafferUI . WidgetSignal ( ) <EOL> if SelectionMenu . __palette is None : <EOL> SelectionMenu . __palette = QtGui . QPalette ( QtGui . QApplication . instance ( ) . palette ( ) ) <EOL> SelectionMenu . __palette . setColor ( QtGui . QPalette . Disabled , QtGui . QPalette . Light , QtGui . QColor ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . _qtWidget ( ) . setPalette ( SelectionMenu . __palette ) <EOL> self . _qtWidget ( ) . setView ( QtGui . QListView ( ) ) <EOL> def selectedSignal ( self ) : <EOL> return self . __selectedSignal <EOL> def currentIndexChangedSignal ( self ) : <EOL> return self . __currentIndexChangedSignal <EOL> def __changed ( self , index ) : <EOL> self . currentIndexChangedSignal ( ) ( self ) <EOL> def __selected ( self , index ) : <EOL> self . selectedSignal ( ) ( self ) <EOL> def addItem ( self , itemName , imageOrImageFileName = None ) : <EOL> self . _qtWidget ( ) . addItem ( itemName ) <EOL> if not imageOrImageFileName is None : <EOL> self . setIcon ( self . getTotal ( ) - <NUM_LIT:1> , imageOrImageFileName ) <EOL> def insertItem ( self , index , itemName , imageOrImageFileName = None ) : <EOL> self . _qtWidget ( ) . insertItem ( index , itemName ) <EOL> if not imageOrImageFileName is None : <EOL> self . setIcon ( index , imageOrImageFileName ) <EOL> def setIcon ( self , index , imageOrImageFileName ) : <EOL> icon = None <EOL> assert ( isinstance ( imageOrImageFileName , ( basestring , GafferUI . Image , type ( None ) ) ) ) <EOL> if isinstance ( imageOrImageFileName , basestring ) : <EOL> icon = GafferUI . Image ( imageOrImageFileName ) <EOL> else : <EOL> icon = imageOrImageFileName <EOL> if icon is not None : <EOL> self . _qtWidget ( ) . setItemIcon ( index , QtGui . QIcon ( icon . _qtPixmap ( ) ) ) <EOL> self . _qtWidget ( ) . setIconSize ( icon . _qtPixmap ( ) . size ( ) ) <EOL> def getIcon ( self , index ) : <EOL> return self . _qtWidget ( ) . itemIcon ( index ) <EOL> def getCurrentIndex ( self ) : <EOL> return self . _qtWidget ( ) . currentIndex ( ) <EOL> def getCurrentItem ( self ) : <EOL> return str ( self . _qtWidget ( ) . currentText ( ) ) <EOL> def getTotal ( self ) : <EOL> return self . _qtWidget ( ) . count ( ) <EOL> def setCurrentIndex ( self , index ) : <EOL> self . _qtWidget ( ) . setCurrentIndex ( index ) <EOL> def getItem ( self , index ) : <EOL> return str ( self . _qtWidget ( ) . itemText ( index ) ) <EOL> def removeIndex ( self , index ) : <EOL> self . _qtWidget ( ) . removeItem ( index ) <EOL> def insertSeparator ( self , index ) : <EOL> self . _qtWidget ( ) . insertSeparator ( index ) </s>
