I'm rewritting a C# Console application in Python, and I'd like to port an indeterminate console-based progress bar class I wrote.
I have examples of creating determinate progress bars using text, but I'm not sure how I would do an indeterminate one. I'm assuming I would need threading of some sort. Thanks for your help!
This is the class:
public class Progress {
String _status = "";
Thread t = null;
public Progress(String status) {
_status = status;
}
public Progress Start() {
t = new Thread(() => {
Console.Write(_status + " ");
while (true) {
Thread.Sleep(300);
Console.Write("\r" + _status + " ");
Thread.Sleep(300);
Console.Write("\r" + _status + " . ");
Thread.Sleep(300);
Console.Write("\r" + _status + " .. ");
Thread.Sleep(300);
Console.Write("\r" + _status + " ...");
}
});
t.Start();
return this;
}
public void Stop(Boolean appendLine = false) {
t.Abort();
Console.Write("\r" + _status + " ... ");
if (appendLine)
Console.WriteLine();
}
}
(P.S. Feel free to take that Progress class)