<s> import ttk <EOL> import Tkinter as tk <EOL> from rwb . runner . log import RobotLogTree , RobotLogMessages <EOL> from rwb . lib import AbstractRwbGui <EOL> from rwb . widgets import Statusbar <EOL> from rwb . runner . listener import RemoteRobotListener <EOL> NAME = "<STR_LIT>" <EOL> HELP_URL = "<STR_LIT>" <EOL> DEFAULT_SETTINGS = { <EOL> NAME : { <EOL> "<STR_LIT:port>" : <NUM_LIT> , <EOL> "<STR_LIT:host>" : "<STR_LIT:localhost>" , <EOL> } <EOL> } <EOL> class MonitorApp ( AbstractRwbGui ) : <EOL> def __init__ ( self ) : <EOL> AbstractRwbGui . __init__ ( self , NAME , DEFAULT_SETTINGS ) <EOL> self . wm_geometry ( "<STR_LIT>" ) <EOL> port = self . get_setting ( "<STR_LIT>" ) <EOL> print "<STR_LIT>" , port <EOL> self . listener = RemoteRobotListener ( self , port = port , callback = self . _listen ) <EOL> self . wm_title ( "<STR_LIT>" % self . listener . port ) <EOL> self . _create_menubar ( ) <EOL> self . _create_statusbar ( ) <EOL> self . _create_notebook ( ) <EOL> self . stack = [ ] <EOL> self . event_id = <NUM_LIT:0> <EOL> def _create_menubar ( self ) : <EOL> self . menubar = tk . Menu ( self ) <EOL> self . configure ( menu = self . menubar ) <EOL> self . file_menu = tk . Menu ( self . menubar , tearoff = False ) <EOL> self . file_menu . add_command ( label = "<STR_LIT>" , command = self . _on_exit ) <EOL> self . help_menu = tk . Menu ( self , tearoff = False ) <EOL> self . help_menu . add_command ( label = "<STR_LIT>" , command = self . _on_view_help ) <EOL> self . help_menu . add_separator ( ) <EOL> self . help_menu . add_command ( label = "<STR_LIT>" , command = self . _on_about ) <EOL> self . menubar . add_cascade ( menu = self . file_menu , label = "<STR_LIT>" , underline = <NUM_LIT:0> ) <EOL> self . menubar . add_cascade ( menu = self . help_menu , label = "<STR_LIT>" , underline = <NUM_LIT:0> ) <EOL> def _on_view_help ( self ) : <EOL> import webbrowser <EOL> webbrowser . open ( HELP_URL ) <EOL> def _on_exit ( self ) : <EOL> self . destroy ( ) <EOL> def _create_statusbar ( self ) : <EOL> self . statusbar = Statusbar ( self ) <EOL> self . statusbar . pack ( side = "<STR_LIT>" , fill = "<STR_LIT:x>" ) <EOL> self . statusbar . add_section ( "<STR_LIT:port>" , <NUM_LIT:12> , "<STR_LIT>" % self . listener . port ) <EOL> self . statusbar . add_progress ( mode = "<STR_LIT>" ) <EOL> def _create_notebook ( self ) : <EOL> self . notebook = ttk . Notebook ( self ) <EOL> self . notebook . pack ( side = "<STR_LIT>" , fill = "<STR_LIT>" , expand = True ) <EOL> self . log_tree = RobotLogTree ( self . notebook , auto_open = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:test>" , "<STR_LIT>" ) ) <EOL> self . log_messages = RobotLogMessages ( self . notebook ) <EOL> self . notebook . add ( self . log_tree , text = "<STR_LIT>" ) <EOL> self . notebook . add ( self . log_messages , text = "<STR_LIT>" ) <EOL> self . notebook . pack ( side = "<STR_LIT>" , fill = "<STR_LIT>" , expand = True ) <EOL> self . listeners = ( self . log_tree , self . log_messages ) <EOL> def _listen ( self , cmd , * args ) : <EOL> self . event_id += <NUM_LIT:1> <EOL> for listener in self . listeners : <EOL> listener . listen ( self . event_id , cmd , args ) <EOL> if cmd in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> name = args [ <NUM_LIT:0> ] <EOL> cmd_type = cmd . split ( "<STR_LIT:_>" ) [ <NUM_LIT:1> ] <EOL> self . stack . append ( ( cmd_type , name ) ) <EOL> self . update_display ( ) <EOL> elif cmd in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> cmd_type = cmd . split ( "<STR_LIT:_>" ) [ <NUM_LIT:1> ] <EOL> self . stack . pop ( ) <EOL> self . update_display ( ) <EOL> def update_display ( self ) : <EOL> if len ( self . stack ) == <NUM_LIT:1> : <EOL> self . statusbar . progress_start ( ) <EOL> elif len ( self . stack ) == <NUM_LIT:0> : <EOL> self . statusbar . progress_stop ( ) <EOL> s = "<STR_LIT:.>" . join ( [ x [ <NUM_LIT:1> ] for x in self . stack ] ) . strip ( ) <EOL> self . statusbar . message ( s , clear = True , lifespan = <NUM_LIT:0> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> app = MonitorApp ( ) <EOL> app . mainloop ( ) </s>
