<s> from PyQt4 import QtGui <EOL> from models . experiment import Experiment <EOL> __author__ = '<STR_LIT>' <EOL> class ExperimentComboBox ( QtGui . QComboBox ) : <EOL> def __init__ ( self , session = None , parent = None ) : <EOL> super ( ExperimentComboBox , self ) . __init__ ( parent ) <EOL> self . session = session <EOL> self . refresh_experiments ( ) <EOL> def refresh_experiments ( self ) : <EOL> self . clear ( ) <EOL> self . experiments = self . session . query ( Experiment ) . all ( ) <EOL> for e in self . experiments : <EOL> self . addItem ( e . name ) <EOL> def currentItem ( self ) : <EOL> try : <EOL> val = self . experiments [ self . currentIndex ( ) ] <EOL> except Exception as e : <EOL> print ( e ) <EOL> return None <EOL> return val </s>
