diff --git a/qcodes/widgets/display.py b/qcodes/widgets/display.py index fab1dfb15fe..6a705dbb2cd 100644 --- a/qcodes/widgets/display.py +++ b/qcodes/widgets/display.py @@ -1,28 +1,34 @@ +"""Helper for adding content stored in a file to a jupyter notebook.""" import os from pkg_resources import resource_string from IPython.display import display, Javascript, HTML +# Originally I implemented this using regular open() and read(), so it +# could use relative paths from the importing file. +# +# But for distributable packages, pkg_resources.resource_string is the +# best way to load data files, because it works even if the package is +# in an egg or zip file. See: +# http://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime + def display_auto(qcodes_path, file_type=None): - ''' - Display some javascript, css, or html content in the notebook - from a package-relative file path. Will use the file extension - to determine file type unless overridden by file_type - - qcodes_path: the path to the target file within the qcodes package - - file_type: optionally override the file extension to determine - what type of file this is - ''' - - # Originally I implemented this using regular open() and read(), so it - # could use relative paths from the importing file. - # - # But for distributable packages, pkg_resources.resource_string is the - # best way to load data files, because it works even if the package is - # in an egg or zip file. See: - # http://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime + """ + Display some javascript, css, or html content in a jupyter notebook. + + Content comes from a package-relative file path. Will use the file + extension to determine file type unless overridden by file_type + + Args: + qcodes_path (str): the path to the target file within the qcodes + package, like 'widgets/widgets.js' + + file_type (Optional[str]): Override the file extension to determine + what type of file this is. Case insensitive, supported values + are 'js', 'css', and 'html' + """ contents = resource_string('qcodes', qcodes_path).decode('utf-8') + if file_type is None: ext = os.path.splitext(qcodes_path)[1].lower() elif 'js' in file_type.lower(): diff --git a/qcodes/widgets/widgets.css b/qcodes/widgets/widgets.css index 8a197fe9ea9..ab4204ae5e4 100644 --- a/qcodes/widgets/widgets.css +++ b/qcodes/widgets/widgets.css @@ -9,10 +9,37 @@ box-shadow: 0 0 12px 1px rgba(87, 87, 87, 0.2); } -.qcodes-output-header { +.qcodes-output-header { float: right; } +.qcodes-highlight { + animation: pulse 1s linear; + background-color: #fa4; +} + +@keyframes pulse { + 0% { + background-color: #f00; + } + 100% { + background-color: #fa4; + } +} + +.qcodes-process-list { + float: left; + max-width: 780px; + margin: 3px 5px 3px 10px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.qcodes-output-view[qcodes-state=minimized] .qcodes-process-list { + max-width: 300px; +} + .qcodes-output-view span { padding: 2px 6px 3px 12px; } diff --git a/qcodes/widgets/widgets.js b/qcodes/widgets/widgets.js index 8188d64e52b..0e99c2169ff 100644 --- a/qcodes/widgets/widgets.js +++ b/qcodes/widgets/widgets.js @@ -56,11 +56,14 @@ require([ var SubprocessView = UpdateView.extend({ render: function() { - var me = window.SPVIEW = this; + var me = this; me._interval = 0; me._minimize = ''; me._restore = ''; + // max lines of output to show + me.maxOutputLength = 500; + // in case there is already an outputView present, // like from before restarting the kernel $('.qcodes-output-view').not(me.$el).remove(); @@ -70,7 +73,8 @@ require([ .attr('qcodes-state', 'docked') .html( '