Show More
@@ -657,15 +657,19 b' class Image(DisplayObject):' | |||
|
657 | 657 | return unicode(s.split('.')[-1].lower()) |
|
658 | 658 | |
|
659 | 659 | |
|
660 | def clear_output(): | |
|
661 |
"""Clear the output of the current cell receiving output. |
|
|
660 | def clear_output(wait=False): | |
|
661 | """Clear the output of the current cell receiving output. | |
|
662 | ||
|
663 | Parameters | |
|
664 | ---------- | |
|
665 | wait : bool [default: false] | |
|
666 | Wait to clear the output until new output is available to replace it.""" | |
|
662 | 667 | from IPython.core.interactiveshell import InteractiveShell |
|
663 | 668 | if InteractiveShell.initialized(): |
|
664 | InteractiveShell.instance().display_pub.clear_output() | |
|
669 | InteractiveShell.instance().display_pub.clear_output(wait) | |
|
665 | 670 | else: |
|
666 | 671 | from IPython.utils import io |
|
667 | 672 | print('\033[2K\r', file=io.stdout, end='') |
|
668 | 673 | io.stdout.flush() |
|
669 | 674 | print('\033[2K\r', file=io.stderr, end='') |
|
670 | 675 | io.stderr.flush() |
|
671 |
@@ -108,7 +108,7 b' class DisplayPublisher(Configurable):' | |||
|
108 | 108 | if 'text/plain' in data: |
|
109 | 109 | print(data['text/plain'], file=io.stdout) |
|
110 | 110 | |
|
111 | def clear_output(self): | |
|
111 | def clear_output(self, wait=False): | |
|
112 | 112 | """Clear the output of the cell receiving output.""" |
|
113 | 113 | print('\033[2K\r', file=io.stdout, end='') |
|
114 | 114 | io.stdout.flush() |
@@ -123,8 +123,8 b' class CapturingDisplayPublisher(DisplayPublisher):' | |||
|
123 | 123 | def publish(self, source, data, metadata=None): |
|
124 | 124 | self.outputs.append((source, data, metadata)) |
|
125 | 125 | |
|
126 | def clear_output(self): | |
|
127 | super(CapturingDisplayPublisher, self).clear_output() | |
|
126 | def clear_output(self, wait=False): | |
|
127 | super(CapturingDisplayPublisher, self).clear_output(wait) | |
|
128 | 128 | if other: |
|
129 | 129 | # empty the list, *do not* reassign a new list |
|
130 | 130 | del self.outputs[:] |
@@ -386,8 +386,8 b' var IPython = (function (IPython) {' | |||
|
386 | 386 | }; |
|
387 | 387 | |
|
388 | 388 | |
|
389 | CodeCell.prototype.clear_output = function () { | |
|
390 | this.output_area.clear_output(); | |
|
389 | CodeCell.prototype.clear_output = function (wait) { | |
|
390 | this.output_area.clear_output(wait); | |
|
391 | 391 | }; |
|
392 | 392 | |
|
393 | 393 |
@@ -31,7 +31,7 b' var IPython = (function (IPython) {' | |||
|
31 | 31 | this.outputs = []; |
|
32 | 32 | this.collapsed = false; |
|
33 | 33 | this.scrolled = false; |
|
34 |
this.clear_ |
|
|
34 | this.clear_queued = null; | |
|
35 | 35 | if (prompt_area === undefined) { |
|
36 | 36 | this.prompt_area = true; |
|
37 | 37 | } else { |
@@ -289,6 +289,12 b' var IPython = (function (IPython) {' | |||
|
289 | 289 | OutputArea.prototype.append_output = function (json, dynamic) { |
|
290 | 290 | // If dynamic is true, javascript output will be eval'd. |
|
291 | 291 | this.expand(); |
|
292 | ||
|
293 | // Clear the output if clear is queued. | |
|
294 | if (this.clear_queued) { | |
|
295 | this.clear_output(false); | |
|
296 | } | |
|
297 | ||
|
292 | 298 | if (json.output_type === 'pyout') { |
|
293 | 299 | this.append_pyout(json, dynamic); |
|
294 | 300 | } else if (json.output_type === 'pyerr') { |
@@ -605,21 +611,32 b' var IPython = (function (IPython) {' | |||
|
605 | 611 | |
|
606 | 612 | |
|
607 | 613 | OutputArea.prototype.handle_clear_output = function (content) { |
|
608 | this.clear_output(); | |
|
614 | this.clear_output(content.wait); | |
|
609 | 615 | }; |
|
610 | 616 | |
|
611 | 617 | |
|
612 | OutputArea.prototype.clear_output = function() { | |
|
613 | ||
|
614 | // Fix the output div's height | |
|
615 | var height = this.element.height(); | |
|
616 | this.element.height(height); | |
|
618 | OutputArea.prototype.clear_output = function(wait) { | |
|
619 | if (wait) { | |
|
617 | 620 | |
|
618 | // clear all, no need for logic | |
|
619 | this.element.html(""); | |
|
620 |
this.output |
|
|
621 | this.unscroll_area(); | |
|
622 | return; | |
|
621 | // If a clear is queued, clear before adding another to the queue. | |
|
622 | if (this.clear_queued) { | |
|
623 | this.clear_output(false); | |
|
624 | }; | |
|
625 | ||
|
626 | this.clear_queued = true; | |
|
627 | } else { | |
|
628 | this.clear_queued = false; | |
|
629 | ||
|
630 | // Fix the output div's height | |
|
631 | var height = this.element.height(); | |
|
632 | this.element.height(height); | |
|
633 | ||
|
634 | // clear all, no need for logic | |
|
635 | this.element.html(""); | |
|
636 | this.outputs = []; | |
|
637 | this.unscroll_area(); | |
|
638 | return; | |
|
639 | }; | |
|
623 | 640 | }; |
|
624 | 641 | |
|
625 | 642 |
@@ -86,8 +86,8 b' class ZMQDisplayPublisher(DisplayPublisher):' | |||
|
86 | 86 | parent=self.parent_header, ident=self.topic, |
|
87 | 87 | ) |
|
88 | 88 | |
|
89 | def clear_output(self): | |
|
90 |
content = |
|
|
89 | def clear_output(self, wait=False): | |
|
90 | content = dict(wait=wait) | |
|
91 | 91 | |
|
92 | 92 | print('\r', file=sys.stdout, end='') |
|
93 | 93 | print('\r', file=sys.stderr, end='') |
@@ -984,6 +984,20 b' Message type: ``status``::' | |||
|
984 | 984 | execution_state : ('busy', 'idle', 'starting') |
|
985 | 985 | } |
|
986 | 986 | |
|
987 | Clear output | |
|
988 | ------------ | |
|
989 | ||
|
990 | This message type is used to clear the output that is visible on the frontend. | |
|
991 | ||
|
992 | Message type: ``clear_output``:: | |
|
993 | ||
|
994 | content = { | |
|
995 | ||
|
996 | # Wait to clear the output until new output is available. Clears the | |
|
997 | # existing output immediately before the new output is displayed. | |
|
998 | # Useful for creating simple animations with minimal flickering. | |
|
999 | 'wait' : bool, | |
|
1000 | } | |
|
987 | 1001 | |
|
988 | 1002 | Messages on the stdin ROUTER/DEALER sockets |
|
989 | 1003 | =========================================== |
General Comments 0
You need to be logged in to leave comments.
Login now