U C^`@shddlmZddlZddlZddlZddlZddlmZddlmZddl m Z m Z Gddde Z dS))print_functionN)Tk) ScrolledText)MonitorTerminatedProcessc@seZdZdZdddZejdddefddd Zejdddefdd d Z ejdddefdd d Z ddZ ddZ ddZ dS) TkMonitorz An interface over a dictionary {taskno: scrolledtext widget}, with methods add_listener, del_listener, notify_listener and start/stop. NcCst|||i|_dSN)r__init__widgets)selfnamequeuer)/tmp/pip-install-6_kvzl1k/plac/plac_tk.pyr szTkMonitor.__init__z task number positional)tasknocCs4t|jdd}|dd||||j|<dS)z%There is a ScrolledText for each task)heightendzOutput of task %d N)rrootinsertpackr )r rstrrr add_listenerszTkMonitor.add_listenercCs |j|=dSr)r )r rrrr del_listenerszTkMonitor.del_listenercCs&|j|}|d|d|dS)Nr )r rupdate)r rmsgwrrrnotify_listener s zTkMonitor.notify_listenercCst|_|j|j|jd|j|jd|jz|jWn<t k rnt dt t jdYntk rYnXdS)zStart the mainloopZWM_DELETE_WINDOWrzProcess %d killed by CTRL-C)fileN)rrtitler Z wm_protocolstopafter read_queueZmainloopKeyboardInterruptprintosgetpidsysstderrrr rrrstart&szTkMonitor.startcCs|jdSr)rquitr+rrrr"3szTkMonitor.stopcCsTz|j}Wntjk r$YnXt||d|dd|jd|jdS)Nrd)r get_nowaitQueueEmptygetattrrr#r$)r cmd_argsrrrr$6s zTkMonitor.read_queue)N)__name__ __module__ __qualname____doc__r plac_core annotationsintrrrr,r"r$rrrrr s     r) __future__rr'r)r1r9TkinterrrZplac_extrrrrrrrs