In [ ]:
###############################################
##     Press the "Run" button above          ##
##     Fernando Pérez-García, 2020           ##
##     [email protected]     ##
###############################################

from pathlib import Path
from IPython.display import Javascript
from IPython.core.display import display, HTML

def say(string, header=True):
    if header: string = f'<h1>{string}</h1>'
    display(HTML(string))

# Download repository
say('Downloading repository...')
repoName = 'Semiology-Visualisation-Tool'
repoDir = Path(f'{repoName}-master')
url = f'https://github.com/thenineteen/{repoName}/archive/master.zip'
archiveFilePath = f'{repoName}.zip'
downloadAndExtractArchive(url, archiveFilePath, '.')

# Install Python module
say('Installing libraries...')
pip_install(f'--quiet --editable {repoDir}')

# Load Python and Slicer modules
say('Loading module...')
moduleFactory = slicer.app.moduleManager().factoryManager()
modulePath = repoDir / 'slicer/SemiologyVisualisation.py'
moduleFactory.registerModule(qt.QFileInfo(str(modulePath)))
moduleFactory.loadModules([modulePath.stem])
selectModule('SemiologyVisualisation')
slicer.semiologyVisualisation.setLiteMode()

# Preload data
say('Loading data...')
slicer.semiologyVisualisation.loadDataButton.clicked()

say('Done. Trying to open in a new tab...')
html = """<a href="../desktop" target="_blank"><img src="https://www.slicer.org/img/3DSlicerLogo-H-Color-218x144.png"/>
<h1><center>Click here to manually open 3D Slicer in a new tab</center></h1></a>"""
say(html, header=False)

display(Javascript('window.open("../desktop");'))