Show More
@@ -129,10 +129,11 b' class CapturingDisplayPublisher(DisplayPublisher):' | |||
|
129 | 129 | transient = kwargs.pop('transient', None) |
|
130 | 130 | update = kwargs.pop('update', False) |
|
131 | 131 | |
|
132 |
self.outputs.append( |
|
|
132 | self.outputs.append({'data':data, 'metadata':metadata, | |
|
133 | 'transient':transient, 'update':update}) | |
|
133 | 134 | |
|
134 | 135 | def clear_output(self, wait=False): |
|
135 | 136 | super(CapturingDisplayPublisher, self).clear_output(wait) |
|
136 | 137 | |
|
137 | 138 | # empty the list, *do not* reassign a new list |
|
138 |
|
|
|
139 | self.outputs.clear() |
@@ -21,13 +21,16 b' else:' | |||
|
21 | 21 | |
|
22 | 22 | |
|
23 | 23 | class RichOutput(object): |
|
24 | def __init__(self, data=None, metadata=None): | |
|
24 | def __init__(self, data=None, metadata=None, transient=None, update=False): | |
|
25 | 25 | self.data = data or {} |
|
26 | 26 | self.metadata = metadata or {} |
|
27 | self.transient = transient or {} | |
|
28 | self.update = update | |
|
27 | 29 | |
|
28 | 30 | def display(self): |
|
29 | 31 | from IPython.display import publish_display_data |
|
30 |
publish_display_data(data=self.data, metadata=self.metadata |
|
|
32 | publish_display_data(data=self.data, metadata=self.metadata, | |
|
33 | transient=self.transient, update=self.update) | |
|
31 | 34 | |
|
32 | 35 | def _repr_mime_(self, mime): |
|
33 | 36 | if mime not in self.data: |
@@ -108,7 +111,7 b' class CapturedIO(object):' | |||
|
108 | 111 | for o in c.outputs: |
|
109 | 112 | display(o) |
|
110 | 113 | """ |
|
111 |
return [ RichOutput( |
|
|
114 | return [ RichOutput(**kargs) for kargs in self._outputs ] | |
|
112 | 115 | |
|
113 | 116 | def show(self): |
|
114 | 117 | """write my output to sys.stdout/err as appropriate""" |
@@ -116,8 +119,8 b' class CapturedIO(object):' | |||
|
116 | 119 | sys.stderr.write(self.stderr) |
|
117 | 120 | sys.stdout.flush() |
|
118 | 121 | sys.stderr.flush() |
|
119 |
for |
|
|
120 |
RichOutput( |
|
|
122 | for kargs in self._outputs: | |
|
123 | RichOutput(**kargs).display() | |
|
121 | 124 | |
|
122 | 125 | __call__ = show |
|
123 | 126 |
General Comments 0
You need to be logged in to leave comments.
Login now