B e]`@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|_dS)N)r__init__widgets)selfnamequeuer j/home/app_decipher_dev_19-4/dev/decipher-analysis/serverless-application/helper/df_spacy/python/plac_tk.pyrszTkMonitor.__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 rstr r r add_listenerszTkMonitor.add_listenercCs |j|=dS)N)r )r rr r r del_listenerszTkMonitor.del_listenercCs&|j|}|d|d|dS)Nr )r rupdate)r rmsgwr r rnotify_listener s zTkMonitor.notify_listenercCst|_|j|j|jd|j|jd|jy|jWn<t k rnt dt t jdYntk rYnXdS)zStart the mainloopZWM_DELETE_WINDOWrzProcess %d killed by CTRL-C)fileN)rrtitler Z wm_protocolstopafter read_queueZmainloopKeyboardInterruptprintosgetpidsysstderrr)r r r rstart&szTkMonitor.startcCs|jdS)N)rquit)r r r rr!3szTkMonitor.stopcCsTy|j}Wntjk r$YnXt||d|dd|jd|jdS)Nrd)r Z get_nowaitQueueZEmptygetattrrr"r#)r Zcmd_argsr r rr#6s zTkMonitor.read_queue)N)__name__ __module__ __qualname____doc__r plac_core annotationsintrrrr*r!r#r r r rr s  r) __future__rr&r(r.r4Tkinterrrplac_extrrrr r r rs