Skip to content

Webwidget streamline python use

Created by: jcfr

Improve use of python from javascript.

@pieper Instead of a systematically re-initialization the QWebChannel, this PR re-refactor the code introducing qSlicerExtensionsInstallWidgetPrivate::initializeWebChannelTransport(QByteArray& webChannelScript) allowing both the base and derives classes to customize the WebChannelTransport initialization call back.

See also this documentation mentioning that only one WebChannel can be initialized only once per page. See http://doc.qt.io/qt-5/qwebenginepage.html#setWebChannel

This means that to evaluate python from a webpage loaded through a qSlicerWebWidget, it is now as simple as doing window.slicerPython.evalPython("print('hello from JS through python')")

Merge request reports