wickedpanda
wickedpanda

Reputation: 39

show user 'processing' animation in python

i just wrote an extremely long script that takes a list of URLs and runs a series of API calls, processes them etc.

Unfortunately for majority of the calls, response is empty (to give scale, i get result for ~100 / 4000 urls )

I'm wondering if there is a way to show in terminal (or powershell) some kind of animation to indicate that the process is still running. Currently - i have the standard blinking underscore.

I was thinking of something like alterating between \ - / |

i definitely don't want to trash the console with printing too much.

does anyone know if something like that is possible ?

Upvotes: 2

Views: 191

Answers (1)

Santiago Squarzon
Santiago Squarzon

Reputation: 61103

This is one way you can do it in PowerShell.

$progress = '\', '|', '/', '-'
$i = 0
[console]::Write('Doing something...')
while($true) {
    $char = $progress[$i++ % $progress.Count]
    [console]::Write("$char$([char]0x8)")
    Start-Sleep -Milliseconds 300
}

Relevant docs:

Upvotes: 0

Related Questions