<s> from PyQt4 import QtCore , QtGui , uic <EOL> import ilastik <EOL> from ilastik . modules . classification . core . classifiers import classifierBase <EOL> import os <EOL> class ClassifierSelectionDlg ( QtGui . QDialog ) : <EOL> def __init__ ( self , ilastikMain ) : <EOL> QtGui . QWidget . __init__ ( self , ilastikMain ) <EOL> self . setWindowTitle ( "<STR_LIT>" ) <EOL> self . ilastik = ilastikMain <EOL> self . previousClassifier = self . currentClassifier = self . ilastik . project . dataMgr . module [ "<STR_LIT>" ] . classifier <EOL> ilastikPath = os . path . dirname ( ilastik . __file__ ) <EOL> uic . loadUi ( ilastikPath + '<STR_LIT>' , self ) <EOL> self . connect ( self . buttonBox , QtCore . SIGNAL ( '<STR_LIT>' ) , self . accept ) <EOL> self . connect ( self . buttonBox , QtCore . SIGNAL ( '<STR_LIT>' ) , self . reject ) <EOL> self . connect ( self . settingsButton , QtCore . SIGNAL ( '<STR_LIT>' ) , self . classifierSettings ) <EOL> self . classifiers = classifierBase . ClassifierBase . __subclasses__ ( ) <EOL> j = <NUM_LIT:0> <EOL> for i , c in enumerate ( self . classifiers ) : <EOL> self . listWidget . addItem ( c . name ) <EOL> if c == self . currentClassifier : <EOL> j = i <EOL> self . connect ( self . listWidget , QtCore . SIGNAL ( '<STR_LIT>' ) , self . currentRowChanged ) <EOL> self . listWidget . setCurrentRow ( j ) <EOL> def currentRowChanged ( self , current ) : <EOL> c = self . currentClassifier = self . classifiers [ current ] <EOL> self . name . setText ( c . name ) <EOL> self . homepage . setText ( c . homepage ) <EOL> self . description . setText ( c . description ) <EOL> self . author . setText ( c . author ) <EOL> func = getattr ( c , "<STR_LIT>" , None ) <EOL> if callable ( func ) : <EOL> self . settingsButton . setVisible ( True ) <EOL> else : <EOL> self . settingsButton . setVisible ( False ) <EOL> def classifierSettings ( self ) : <EOL> self . currentClassifier . settings ( ) <EOL> def exec_ ( self ) : <EOL> if QtGui . QDialog . exec_ ( self ) == QtGui . QDialog . Accepted : <EOL> return self . currentClassifier <EOL> else : <EOL> return self . previousClassifier <EOL> def test ( ) : <EOL> app = QtGui . QApplication ( [ "<STR_LIT>" ] ) <EOL> dialog = ClassifierSelectionDlg ( ) <EOL> print dialog . show ( ) <EOL> app . exec_ ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test ( ) <EOL> test ( ) </s>
