Skip to content

Avoid flickering#210

Merged
wolph merged 1 commit into
wolph:developfrom
paulo-raca:blanks
Sep 30, 2019
Merged

Avoid flickering#210
wolph merged 1 commit into
wolph:developfrom
paulo-raca:blanks

Conversation

@paulo-raca

Copy link
Copy Markdown
Contributor

StdRedirectMixin makes the bar erase itself before writing the new update.

This works fine and is invisible most of the time.
But only most of the time -- If the refreshes are very fast, flickering becomes visible

This PR first checks if there is something buffered to be written in stdout/stderr, and doesn't erase the current line otherwise

StdRedirectMixin makes the bar erase itself before writing the new update.
This works fine and is invisible most of the time.

Most of the time -- If the refreshes are very fast, flickering becomes visible

This PR first checks if there is something buffered to be written in stdout/stderr, and doesn't erase the current line otherwise
@wolph

wolph commented Sep 30, 2019

Copy link
Copy Markdown
Owner

It took me a while to look at this, but I'm wondering if there is a need for this because there is already a detection for that:

https://github.com/WoLpH/python-progressbar/blob/develop/progressbar/utils.py#L154-L160

I should note that this is also a bit terminal dependent, many terminals won't really show the flickering at all. Which one are you using?

@paulo-raca

Copy link
Copy Markdown
Contributor Author

The existing check copies the internal buffer to stdout/stderr if there is something to be copied, which makes sense.

The issue is that the output line always gets overwritten by blanks and then rewritten, which is what this PR fixes.

I'm using Konsole, and it works without issues most of the time -- It was only when I accidentally started calling update in a close loop that the flickering was visible.

@wolph

wolph commented Sep 30, 2019

Copy link
Copy Markdown
Owner

Ah, now I see what you mean.

There might actually be an easier method to take care of this because I don't think the flushing is needed in all cases anymore. But I'm a bit hesitant to change it, the handling of output is very sensitive to breakage, even the is_terminal change caused a bug with jupyter-notebooks already :)
Because different terminals have different ways of handling outputs... well, things tend to break at times.

Anyhow, the write method of a wrapped IO already has a check for newlines, I could add that as an attribute https://github.com/WoLpH/python-progressbar/blob/develop/progressbar/utils.py#L145-L147

That code checks for newlines, so it should indicate the need for writing the new line (or not)
I've merged your changes with a few alterations and added tests :)

@wolph wolph merged commit c2b7b02 into wolph:develop Sep 30, 2019
@paulo-raca

Copy link
Copy Markdown
Contributor Author

This project was really fun to work on, and you have been very receptive to my PRs, thank you very much!

This is all I had, I'm probably leaving you in peace now :)

@wolph

wolph commented Sep 30, 2019

Copy link
Copy Markdown
Owner

Thank you for all of the help :)
You're definitely the 🥇 contributor to the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants