<s> from atom . api import ( <EOL> Bool , Unicode , Typed , ForwardTyped , Event , Callable , observe <EOL> ) <EOL> from enaml . application import deferred_call <EOL> from enaml . core . declarative import d_ <EOL> from . toolkit_object import ToolkitObject , ProxyToolkitObject <EOL> class ProxyToolkitDialog ( ProxyToolkitObject ) : <EOL> """<STR_LIT>""" <EOL> declaration = ForwardTyped ( lambda : ToolkitDialog ) <EOL> def set_title ( self , title ) : <EOL> raise NotImplementedError <EOL> def show ( self ) : <EOL> raise NotImplementedError <EOL> def open ( self ) : <EOL> raise NotImplementedError <EOL> def exec_ ( self ) : <EOL> raise NotImplementedError <EOL> def accept ( self ) : <EOL> raise NotImplementedError <EOL> def reject ( self ) : <EOL> raise NotImplementedError <EOL> class ToolkitDialog ( ToolkitObject ) : <EOL> """<STR_LIT>""" <EOL> title = d_ ( Unicode ( ) ) <EOL> callback = d_ ( Callable ( ) ) <EOL> destroy_on_close = d_ ( Bool ( True ) ) <EOL> accepted = d_ ( Event ( ) , writable = False ) <EOL> rejected = d_ ( Event ( ) , writable = False ) <EOL> finished = d_ ( Event ( bool ) , writable = False ) <EOL> result = Bool ( False ) <EOL> proxy = Typed ( ProxyToolkitDialog ) <EOL> def show ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . is_initialized : <EOL> self . initialize ( ) <EOL> if not self . proxy_is_active : <EOL> self . activate_proxy ( ) <EOL> self . _prepare ( ) <EOL> self . proxy . show ( ) <EOL> def open ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . is_initialized : <EOL> self . initialize ( ) <EOL> if not self . proxy_is_active : <EOL> self . activate_proxy ( ) <EOL> self . _prepare ( ) <EOL> self . proxy . open ( ) <EOL> def exec_ ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . is_initialized : <EOL> self . initialize ( ) <EOL> if not self . proxy_is_active : <EOL> self . activate_proxy ( ) <EOL> self . _prepare ( ) <EOL> self . proxy . exec_ ( ) <EOL> return self . result <EOL> def accept ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . proxy_is_active : <EOL> self . proxy . accept ( ) <EOL> def reject ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . proxy_is_active : <EOL> self . proxy . reject ( ) <EOL> @ observe ( '<STR_LIT:title>' ) <EOL> def _update_proxy ( self , change ) : <EOL> """<STR_LIT>""" <EOL> super ( ToolkitDialog , self ) . _update_proxy ( change ) <EOL> def _proxy_finished ( self , result ) : <EOL> """<STR_LIT>""" <EOL> self . result = result <EOL> self . finished ( result ) <EOL> if result : <EOL> self . accepted ( ) <EOL> else : <EOL> self . rejected ( ) <EOL> if self . callback : <EOL> self . callback ( self ) <EOL> if self . destroy_on_close : <EOL> deferred_call ( self . destroy ) <EOL> def _prepare ( self ) : <EOL> """<STR_LIT>""" <EOL> self . result = False </s>
