Show More
@@ -26,7 +26,7 b" __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown'," | |||
|
26 | 26 | 'display_javascript', 'display_pdf', 'DisplayObject', 'TextDisplayObject', |
|
27 | 27 | 'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'JSON', 'Javascript', |
|
28 | 28 | 'Image', 'clear_output', 'set_matplotlib_formats', 'set_matplotlib_close', |
|
29 | 'publish_display_data'] | |
|
29 | 'publish_display_data', 'update_display'] | |
|
30 | 30 | |
|
31 | 31 | #----------------------------------------------------------------------------- |
|
32 | 32 | # utility functions |
@@ -78,7 +78,7 b' def _display_mimetype(mimetype, objs, raw=False, metadata=None):' | |||
|
78 | 78 | # Main functions |
|
79 | 79 | #----------------------------------------------------------------------------- |
|
80 | 80 | |
|
81 | def publish_display_data(data, metadata=None, source=None): | |
|
81 | def publish_display_data(data, metadata=None, source=None, transient=None, **kwargs): | |
|
82 | 82 | """Publish data and metadata to all frontends. |
|
83 | 83 | |
|
84 | 84 | See the ``display_data`` message in the messaging documentation for |
@@ -113,11 +113,15 b' def publish_display_data(data, metadata=None, source=None):' | |||
|
113 | 113 | to specify metadata about particular representations. |
|
114 | 114 | source : str, deprecated |
|
115 | 115 | Unused. |
|
116 | traisient : dict | |
|
117 | A dictionary of transient data. | |
|
116 | 118 | """ |
|
117 | 119 | from IPython.core.interactiveshell import InteractiveShell |
|
118 | 120 | InteractiveShell.instance().display_pub.publish( |
|
119 | 121 | data=data, |
|
120 | 122 | metadata=metadata, |
|
123 | transient=transient, | |
|
124 | **kwargs | |
|
121 | 125 | ) |
|
122 | 126 | |
|
123 | 127 | def display(*objs, **kwargs): |
@@ -145,11 +149,22 b' def display(*objs, **kwargs):' | |||
|
145 | 149 | A dictionary of metadata to associate with the output. |
|
146 | 150 | mime-type keys in this dictionary will be associated with the individual |
|
147 | 151 | representation formats, if they exist. |
|
152 | transient : dict, optional | |
|
153 | A dictionary of transient data to associate with the output. | |
|
154 | Data in this dict should not be persisted to files (e.g. notebooks). | |
|
155 | display_id : str, optional | |
|
156 | Set an id for the display. | |
|
157 | This id can be used for updating this display area later via update_display. | |
|
148 | 158 | """ |
|
149 |
raw = kwargs. |
|
|
150 |
include = kwargs. |
|
|
151 |
exclude = kwargs. |
|
|
152 |
metadata = kwargs. |
|
|
159 | raw = kwargs.pop('raw', False) | |
|
160 | include = kwargs.pop('include', None) | |
|
161 | exclude = kwargs.pop('exclude', None) | |
|
162 | metadata = kwargs.pop('metadata', None) | |
|
163 | transient = kwargs.setdefault('transient', {}) | |
|
164 | if 'display_id' in kwargs: | |
|
165 | transient['display_id'] = kwargs.pop('display_id') | |
|
166 | if kwargs.get('update') and 'display_id' not in transient: | |
|
167 | raise TypeError('display_id required for update_display') | |
|
153 | 168 | |
|
154 | 169 | from IPython.core.interactiveshell import InteractiveShell |
|
155 | 170 | |
@@ -158,7 +173,7 b' def display(*objs, **kwargs):' | |||
|
158 | 173 | |
|
159 | 174 | for obj in objs: |
|
160 | 175 | if raw: |
|
161 | publish_display_data(data=obj, metadata=metadata) | |
|
176 | publish_display_data(data=obj, metadata=metadata, **kwargs) | |
|
162 | 177 | else: |
|
163 | 178 | format_dict, md_dict = format(obj, include=include, exclude=exclude) |
|
164 | 179 | if not format_dict: |
@@ -167,7 +182,14 b' def display(*objs, **kwargs):' | |||
|
167 | 182 | if metadata: |
|
168 | 183 | # kwarg-specified metadata gets precedence |
|
169 | 184 | _merge(md_dict, metadata) |
|
170 |
publish_display_data(data=format_dict, metadata=md_dict |
|
|
185 | publish_display_data(data=format_dict, metadata=md_dict, | |
|
186 | **kwargs) | |
|
187 | ||
|
188 | ||
|
189 | def update_display(*objs, **kwargs): | |
|
190 | """Update an existing display""" | |
|
191 | kwargs['update'] = True | |
|
192 | return display(*objs, **kwargs) | |
|
171 | 193 | |
|
172 | 194 | |
|
173 | 195 | def display_pretty(*objs, **kwargs): |
@@ -52,7 +52,7 b' class DisplayPublisher(Configurable):' | |||
|
52 | 52 | if not isinstance(metadata, dict): |
|
53 | 53 | raise TypeError('metadata must be a dict, got: %r' % data) |
|
54 | 54 | |
|
55 | def publish(self, data, metadata=None, source=None): | |
|
55 | def publish(self, data, metadata=None, source=None, **kwargs): | |
|
56 | 56 | """Publish data and metadata to all frontends. |
|
57 | 57 | |
|
58 | 58 | See the ``display_data`` message in the messaging documentation for |
General Comments 0
You need to be logged in to leave comments.
Login now