<s> from __future__ import division <EOL> from vistrails . core . modules import basic_modules <EOL> from vistrails . core . modules . vistrails_module import Module , ModuleError <EOL> from vistrails . core . packagemanager import get_package_manager <EOL> from PyQt4 import QtGui <EOL> class Dialog ( Module ) : <EOL> _input_ports = [ ( '<STR_LIT:title>' , basic_modules . String , <EOL> { '<STR_LIT>' : True } ) , <EOL> ( '<STR_LIT>' , basic_modules . Boolean , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) ] <EOL> cacheable_dialog = False <EOL> def is_cacheable ( self ) : <EOL> return self . cacheable_dialog <EOL> class TextDialog ( Dialog ) : <EOL> _input_ports = [ ( '<STR_LIT:label>' , basic_modules . String , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) , <EOL> ( '<STR_LIT:default>' , basic_modules . String , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) ] <EOL> _output_ports = [ ( '<STR_LIT:result>' , basic_modules . String ) ] <EOL> mode = QtGui . QLineEdit . Normal <EOL> def compute ( self ) : <EOL> if self . has_input ( '<STR_LIT:title>' ) : <EOL> title = self . get_input ( '<STR_LIT:title>' ) <EOL> else : <EOL> title = '<STR_LIT>' <EOL> label = self . get_input ( '<STR_LIT:label>' ) <EOL> default = self . get_input ( '<STR_LIT:default>' ) <EOL> self . cacheable_dialog = self . get_input ( '<STR_LIT>' ) <EOL> ( result , ok ) = QtGui . QInputDialog . getText ( None , title , label , <EOL> self . mode , <EOL> default ) <EOL> if not ok : <EOL> raise ModuleError ( self , "<STR_LIT>" ) <EOL> self . set_output ( '<STR_LIT:result>' , str ( result ) ) <EOL> class PasswordDialog ( TextDialog ) : <EOL> _input_ports = [ ( '<STR_LIT:label>' , basic_modules . String , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) ] <EOL> mode = QtGui . QLineEdit . Password <EOL> class YesNoDialog ( Dialog ) : <EOL> _input_ports = [ ( '<STR_LIT:label>' , basic_modules . String , <EOL> { '<STR_LIT>' : True , '<STR_LIT>' : "<STR_LIT>" } ) ] <EOL> _output_ports = [ ( '<STR_LIT:result>' , basic_modules . Boolean ) ] <EOL> def compute ( self ) : <EOL> if self . has_input ( '<STR_LIT:title>' ) : <EOL> title = self . get_input ( '<STR_LIT:title>' ) <EOL> else : <EOL> title = '<STR_LIT>' <EOL> label = self . get_input ( '<STR_LIT:label>' ) <EOL> self . cacheable_dialog = self . get_input ( '<STR_LIT>' ) <EOL> result = QtGui . QMessageBox . question ( <EOL> None , <EOL> title , label , <EOL> QtGui . QMessageBox . Yes | QtGui . QMessageBox . No ) <EOL> result = result == QtGui . QMessageBox . Yes <EOL> self . set_output ( '<STR_LIT:result>' , result ) <EOL> _modules = [ ( Dialog , { '<STR_LIT>' : True } ) , <EOL> TextDialog , PasswordDialog , <EOL> YesNoDialog ] <EOL> pm = get_package_manager ( ) <EOL> if pm . has_package ( '<STR_LIT>' ) : <EOL> from . continue_prompt import _modules as continue_modules <EOL> _modules . extend ( continue_modules ) </s>
