<s> from __future__ import division <EOL> from PyQt4 import QtCore , QtGui <EOL> from vistrails . core . configuration import get_vistrails_configuration <EOL> from vistrails . core . modules import basic_modules <EOL> from vistrails . core . modules . vistrails_module import Module , ModuleError <EOL> from vistrails . packages . spreadsheet . basic_widgets import SpreadsheetCell <EOL> from vistrails . packages . spreadsheet . spreadsheet_cell import QCellContainer <EOL> class PromptWindow ( QtGui . QDialog ) : <EOL> def __init__ ( self , widget , label = None ) : <EOL> QtGui . QDialog . __init__ ( self ) <EOL> self . setWindowTitle ( "<STR_LIT>" ) <EOL> self . setLayout ( QtGui . QVBoxLayout ( ) ) <EOL> self . layout ( ) . addWidget ( widget ) <EOL> if label is not None : <EOL> self . layout ( ) . addWidget ( QtGui . QLabel ( label ) ) <EOL> buttons = QtGui . QDialogButtonBox ( <EOL> QtGui . QDialogButtonBox . Yes | QtGui . QDialogButtonBox . No ) <EOL> self . connect ( buttons , QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> self , QtCore . SLOT ( '<STR_LIT>' ) ) <EOL> self . connect ( buttons , QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> self , QtCore . SLOT ( '<STR_LIT>' ) ) <EOL> self . layout ( ) . addWidget ( buttons ) <EOL> class PromptIsOkay ( Module ) : <EOL> _input_ports = [ ( '<STR_LIT:label>' , basic_modules . String , <EOL> { '<STR_LIT>' : True } ) , <EOL> ( '<STR_LIT>' , basic_modules . Boolean , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) , <EOL> ( '<STR_LIT>' , SpreadsheetCell ) ] <EOL> _output_ports = [ ( '<STR_LIT:result>' , basic_modules . Boolean ) ] <EOL> def compute ( self ) : <EOL> vt_configuration = get_vistrails_configuration ( ) <EOL> if not getattr ( vt_configuration , '<STR_LIT>' , False ) : <EOL> self . set_output ( '<STR_LIT:result>' , True ) <EOL> return <EOL> cell = self . get_input ( '<STR_LIT>' ) <EOL> label = self . force_get_input ( '<STR_LIT:label>' , None ) <EOL> oldparent = cell . parent ( ) <EOL> assert isinstance ( oldparent , QCellContainer ) <EOL> ncell = oldparent . takeWidget ( ) <EOL> assert ncell == cell <EOL> dialog = PromptWindow ( cell , label ) <EOL> result = dialog . exec_ ( ) == QtGui . QDialog . Accepted <EOL> oldparent . setWidget ( cell ) <EOL> self . set_output ( '<STR_LIT:result>' , result ) <EOL> if not result and not self . get_input ( '<STR_LIT>' ) : <EOL> raise ModuleError ( self , "<STR_LIT>" ) <EOL> _modules = [ PromptIsOkay ] </s>
