<s> import sys <EOL> from PySide import QtGui , QtCore <EOL> from HAppkit_Editors import EditorFactory , GetterSetterController , BaseInspector <EOL> from kraken . core . kraken_system import KrakenSystem <EOL> class ComponentInspector ( BaseInspector ) : <EOL> def __init__ ( self , component , parent = None , nodeItem = None ) : <EOL> super ( ComponentInspector , self ) . __init__ ( objectname = '<STR_LIT>' , parent = parent ) <EOL> self . component = component <EOL> self . nodeItem = nodeItem <EOL> self . setWindowTitle ( self . component . getName ( ) + "<STR_LIT::>" + self . component . getTypeName ( ) ) <EOL> self . setWindowFlags ( QtCore . Qt . Dialog ) <EOL> self . resize ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . refresh ( ) <EOL> def refresh ( self , data = None ) : <EOL> self . clear ( ) <EOL> def setName ( value ) : <EOL> origName = self . nodeItem . getName ( ) <EOL> self . component . setName ( value ) <EOL> if origName != self . component . getDecoratedName ( ) : <EOL> self . nodeItem . setName ( self . component . getDecoratedName ( ) ) <EOL> def getName ( ) : <EOL> return self . component . getName ( ) <EOL> nameController = GetterSetterController ( '<STR_LIT:name>' , '<STR_LIT>' , getter = getName , setter = setName ) <EOL> self . nameWidget = EditorFactory . constructEditor ( nameController , parent = self ) <EOL> self . addEditor ( "<STR_LIT:name>" , self . nameWidget ) <EOL> def setLocation ( value ) : <EOL> origName = self . nodeItem . getName ( ) <EOL> self . component . setLocation ( value ) <EOL> if origName != self . component . getDecoratedName ( ) : <EOL> self . nodeItem . setName ( self . component . getDecoratedName ( ) ) <EOL> def getLocation ( ) : <EOL> return self . component . getLocation ( ) <EOL> locationController = GetterSetterController ( '<STR_LIT:location>' , '<STR_LIT>' , getter = getLocation , setter = setLocation ) <EOL> locationWidget = EditorFactory . constructEditor ( locationController , parent = self ) <EOL> self . addEditor ( "<STR_LIT:location>" , locationWidget ) <EOL> def displayAttribute ( attribute ) : <EOL> def setValue ( value ) : <EOL> attribute . setValue ( value ) <EOL> def getValue ( ) : <EOL> return attribute . getValue ( ) <EOL> attributeController = GetterSetterController ( attribute . getName ( ) , attribute . getDataType ( ) , getter = getValue , setter = setValue ) <EOL> if attribute . getDataType ( ) in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> attributeController . setOption ( '<STR_LIT>' , { '<STR_LIT>' : attribute . getMin ( ) , '<STR_LIT>' : attribute . getMax ( ) } ) <EOL> attributeWidget = EditorFactory . constructEditor ( attributeController , parent = self ) <EOL> self . addEditor ( attribute . getName ( ) , attributeWidget ) <EOL> for i in xrange ( self . component . getNumAttributeGroups ( ) ) : <EOL> attrGrp = self . component . getAttributeGroupByIndex ( i ) <EOL> if attrGrp . getName ( ) == "<STR_LIT>" : <EOL> continue <EOL> grp = self . component . getAttributeGroupByIndex ( i ) <EOL> self . addSeparator ( grp . getName ( ) ) <EOL> for j in xrange ( grp . getNumAttributes ( ) ) : <EOL> displayAttribute ( grp . getAttributeByIndex ( j ) ) <EOL> self . addStretch ( <NUM_LIT:2> ) <EOL> def closeEvent ( self , event ) : <EOL> if self . nodeItem is not None : <EOL> self . nodeItem . inspectorClosed ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> from kraken_components . biped . arm_component import ArmComponentGuide <EOL> armGuide = ArmComponentGuide ( "<STR_LIT>" ) <EOL> widget = ComponentInspector ( component = armGuide ) <EOL> widget . show ( ) <EOL> sys . exit ( app . exec_ ( ) ) </s>
