Start live rendering display. Args: refresh (bool, optional): Also refresh. Defaults to False.
(self, refresh: bool = False)
| 109 | return renderable or "" |
| 110 | |
| 111 | def start(self, refresh: bool = False) -> None: |
| 112 | """Start live rendering display. |
| 113 | |
| 114 | Args: |
| 115 | refresh (bool, optional): Also refresh. Defaults to False. |
| 116 | """ |
| 117 | with self._lock: |
| 118 | if self._started: |
| 119 | return |
| 120 | self._started = True |
| 121 | |
| 122 | if not self.console.set_live(self): |
| 123 | self._nested = True |
| 124 | return |
| 125 | |
| 126 | if self._screen: |
| 127 | self._alt_screen = self.console.set_alt_screen(True) |
| 128 | self.console.show_cursor(False) |
| 129 | self._enable_redirect_io() |
| 130 | self.console.push_render_hook(self) |
| 131 | if refresh: |
| 132 | try: |
| 133 | self.refresh() |
| 134 | except Exception: |
| 135 | # If refresh fails, we want to stop the redirection of sys.stderr, |
| 136 | # so the error stacktrace is properly displayed in the terminal. |
| 137 | # (or, if the code that calls Rich captures the exception and wants to display something, |
| 138 | # let this be displayed in the terminal). |
| 139 | self.stop() |
| 140 | raise |
| 141 | if self.auto_refresh: |
| 142 | self._refresh_thread = _RefreshThread(self, self.refresh_per_second) |
| 143 | self._refresh_thread.start() |
| 144 | |
| 145 | def stop(self) -> None: |
| 146 | """Stop live rendering display.""" |