Did I find the right examples for you? yes no

All Samples(12)  |  Call(8)  |  Derive(0)  |  Import(4)
Write some text, then backspace to original position

Does not work correctly if there is a newline in the string.

        def write_static(s):
    """ Write some text, then backspace to original position
    
    Does not work correctly if there is a newline in the string.
    """
    sys.stdout.write('\b%s%s' % (s, '\b'*len(s)))
    sys.stdout.flush()
        


src/e/n/encore-0.5.1/encore/terminal/progress_display.py   encore(Download)
# Local imports
from encore.events.api import ProgressStartEvent, ProgressStepEvent, ProgressEndEvent
from .utils import write_static
 
 
    def step_listener(self, event):
        if time.time() - self.last_time >= 0.05:
            stars = int(round(float(event.step)/self.steps*self._max))
            write_static(self._format % (event.step, '*'*(stars)))
            self.last_time = time.time()
        self.last_step = event.step
 
    def end_listener(self, event):
        if event.exit_state == 'normal':
            write_static(self._format % (self.last_step, '*'*self._max))
    def step_listener(self, event):
        if time.time() - self.last_time >= 0.05:
            write_static(self._format % ('\|/-'[self._count % 4], event.message[:self._max]))
            self._count += 1
            self.last_time = time.time()
 
    def end_listener(self, event):
        if event.exit_state == 'normal':
            write_static(self._format % (' ', 'Done.'))

src/e/n/encore-HEAD/encore/terminal/progress_display.py   encore(Download)
# Local imports
from encore.events.api import ProgressStartEvent, ProgressStepEvent, ProgressEndEvent
from .utils import write_static
 
 
    def step_listener(self, event):
        if time.time() - self.last_time >= 0.05:
            stars = int(round(float(event.step)/self.steps*self._max))
            write_static(self._format % (event.step, '*'*(stars)))
            self.last_time = time.time()
        self.last_step = event.step
 
    def end_listener(self, event):
        if event.exit_state == 'normal':
            write_static(self._format % (self.last_step, '*'*self._max))
    def step_listener(self, event):
        if time.time() - self.last_time >= 0.05:
            write_static(self._format % ('\|/-'[self._count % 4], event.message[:self._max]))
            self._count += 1
            self.last_time = time.time()
 
    def end_listener(self, event):
        if event.exit_state == 'normal':
            write_static(self._format % (' ', 'Done.'))

src/e/n/encore-0.5.1/encore/terminal/api.py   encore(Download)
# Local imports
from .progress_display import ProgressDisplay, SpinWriter, ProgressWriter
from .utils import write_static

src/e/n/encore-HEAD/encore/terminal/api.py   encore(Download)
# Local imports
from .progress_display import ProgressDisplay, SpinWriter, ProgressWriter
from .utils import write_static