<s> from efl import ecore <EOL> from efl . elementary . box import Box <EOL> from efl . elementary . frame import Frame <EOL> from efl . elementary . button import Button <EOL> from efl . elementary . entry import Entry <EOL> from efl . evas import EVAS_HINT_EXPAND , EVAS_HINT_FILL <EOL> EXPAND_BOTH = EVAS_HINT_EXPAND , EVAS_HINT_EXPAND <EOL> EXPAND_HORIZ = EVAS_HINT_EXPAND , <NUM_LIT:0.0> <EOL> FILL_BOTH = EVAS_HINT_FILL , EVAS_HINT_FILL <EOL> FILL_HORIZ = EVAS_HINT_FILL , <NUM_LIT:0.5> <EOL> class EmbeddedTerminal ( Box ) : <EOL> def __init__ ( self , parent_widget , titles = None , * args , ** kwargs ) : <EOL> Box . __init__ ( self , parent_widget , * args , ** kwargs ) <EOL> self . outPut = Entry ( self , size_hint_weight = EXPAND_BOTH , size_hint_align = FILL_BOTH ) <EOL> self . outPut . editable_set ( False ) <EOL> self . outPut . scrollable_set ( True ) <EOL> self . outPut . callback_changed_add ( self . changedCb ) <EOL> self . outPut . show ( ) <EOL> frame = Frame ( self , size_hint_weight = EXPAND_HORIZ , size_hint_align = FILL_HORIZ ) <EOL> frame . text = "<STR_LIT>" <EOL> frame . autocollapse_set ( True ) <EOL> frame . collapse_go ( True ) <EOL> frame . show ( ) <EOL> bx = Box ( self , size_hint_weight = EXPAND_HORIZ , size_hint_align = FILL_HORIZ ) <EOL> bx . horizontal = True <EOL> bx . show ( ) <EOL> frame . content = bx <EOL> self . inPut = Entry ( self , size_hint_weight = EXPAND_BOTH , size_hint_align = FILL_BOTH ) <EOL> self . inPut . single_line_set ( True ) <EOL> self . inPut . callback_activated_add ( self . enterPressed ) <EOL> self . inPut . show ( ) <EOL> enterButton = Button ( self ) <EOL> enterButton . text = "<STR_LIT>" <EOL> enterButton . callback_pressed_add ( self . enterPressed ) <EOL> enterButton . show ( ) <EOL> bx . pack_end ( self . inPut ) <EOL> bx . pack_end ( enterButton ) <EOL> self . pack_end ( self . outPut ) <EOL> self . pack_end ( frame ) <EOL> self . cmd_exe = None <EOL> self . done_cb = None <EOL> def changedCb ( self , obj ) : <EOL> obj . cursor_end_set ( ) <EOL> def enterPressed ( self , btn ) : <EOL> if not self . cmd_exe : <EOL> self . runCommand ( self . inPut . text ) <EOL> self . inPut . text = "<STR_LIT>" <EOL> else : <EOL> ourResult = self . cmd_exe . send ( "<STR_LIT>" % self . inPut . text ) <EOL> self . inPut . text = "<STR_LIT>" <EOL> def runCommand ( self , command , done_cb = None ) : <EOL> self . cmd_exe = cmd = ecore . Exe ( <EOL> command , <EOL> ecore . ECORE_EXE_PIPE_READ | <EOL> ecore . ECORE_EXE_PIPE_ERROR | <EOL> ecore . ECORE_EXE_PIPE_WRITE <EOL> ) <EOL> cmd . on_add_event_add ( self . command_started ) <EOL> cmd . on_data_event_add ( self . received_data ) <EOL> cmd . on_error_event_add ( self . received_error ) <EOL> cmd . on_del_event_add ( self . command_done ) <EOL> self . done_cb = done_cb <EOL> def command_started ( self , cmd , event , * args , ** kwargs ) : <EOL> self . outPut . entry_append ( "<STR_LIT>" ) <EOL> self . outPut . entry_append ( "<STR_LIT>" ) <EOL> def received_data ( self , cmd , event , * args , ** kwargs ) : <EOL> self . outPut . entry_append ( "<STR_LIT:%s>" % event . data ) <EOL> self . outPut . entry_append ( "<STR_LIT>" ) <EOL> def received_error ( self , cmd , event , * args , ** kwargs ) : <EOL> self . outPut . entry_append ( "<STR_LIT>" % event . data ) <EOL> def command_done ( self , cmd , event , * args , ** kwargs ) : <EOL> self . outPut . entry_append ( "<STR_LIT>" ) <EOL> self . outPut . entry_append ( "<STR_LIT>" ) <EOL> self . cmd_exe = None <EOL> if self . done_cb : <EOL> if callable ( self . done_cb ) : <EOL> self . done_cb ( ) </s>
