[docs]defshowBoolStatus(value,description,invertcolor=False):"""Pretty prints the status of a boolean variable *value* along with the provided description in a green color for True and in a red color for False values. *invertcolor* allows to flip the color assignment."""fromIPython.displayimportHTML,displaystatuscolor="darkgreen"ifvalue^invertcolor:statuscolor="darkred"descr=description[0].lower()+description[1:-1]ifdescription[-1].isalnum():descr+=description[-1]statustext='<h4 style="color: {};">Yes, {}!</h4>'.format(statuscolor,descr)ifvalue:statustext='<h4 style="color: {};">Do not {}!</h4>'.format(statuscolor,descr)display(HTML(f'<div style="border-style: solid; border-color: {statuscolor};'" border-width: 1px; padding: 0em 1em .5em 1em; margin: 1em 0em;"f' width: {len(descr)*0.75}em;">'+statustext+"</div>"))
defon_update(self,change):iflen(change["new"])>0:self.refresh(change["new"][0])defrefresh(self,item):path=os.path.abspath(os.path.join(self.cwd,item))ifos.path.isfile(path):ifself.select_file:self.accord.set_title(0,path)self.file=pathself.accord.selected_index=Noneelse:self.select.value=()else:# os.path.isdir(path)self.file=Noneself.cwd=path# Build list of files and dirskeys=["[..]"]foriteminos.listdir(path):ifitem[0]==".":continueelifos.path.isdir(os.path.join(path,item)):keys.append("["+item+"]")else:keys.append(item)# Sort and create list of output valueskeys.sort(key=str.lower)vals=[]forkinkeys:ifk[0]=="[":vals.append(k[1:-1])# strip off bracketselse:vals.append(k)# Update widgetself.accord.set_title(0,path)self.select.options=list(zip(keys,vals))withself.select.hold_trait_notifications():self.select.value=()