Skip to content

Commit

Permalink
add --ExecutePreprocessor.store_widget_state=True/False flag
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Mar 22, 2019
1 parent 5ea8066 commit 9877c9e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nbconvert/preprocessors/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ class ExecutePreprocessor(Preprocessor):
)
).tag(config=True)

store_widget_state = Bool(True,
help=dedent(
"""
If `True` (default), then the state of the Jupyter widgets created
at the kernel will be stored in the metadata of the notebook.
"""
)
).tag(config=True)

iopub_timeout = Integer(4, allow_none=False,
help=dedent(
"""
Expand Down Expand Up @@ -554,7 +563,7 @@ def clear_display_id_mapping(self, cell_index):
def handle_comm_msg(self, outs, msg, cell_index):
content = msg['content']
data = content['data']
if 'state' in data: # ignore custom msg'es
if self.store_widget_state and 'state' in data: # ignore custom msg'es
self.widget_state.setdefault(content['comm_id'], {}).update(data['state'])
if 'buffer_paths' in data and data['buffer_paths']:
self.widget_buffers[content['comm_id']] = _get_buffer_data(msg)
Expand Down

0 comments on commit 9877c9e

Please sign in to comment.