8000 remove evt.Skip() from EVT_PAINT handler by DietmarSchwertberger · Pull Request #10192 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

remove evt.Skip() from EVT_PAINT handler #10192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DietmarSchwertberger
Copy link
Contributor

PR Summary

Currently evt.Skip() is called at the end of the EVT_PAINT handler.
This should not be done and causes errors on screen when the canvas is redrawn partially, e.g. when a window is dragged over the canvas.
Strange enough, the errors don't occur always, but e.g. with "embedding_in_wx2.py" on Windows 7, 64 bit.

repaint

PR Checklist

-> not applicable

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v2.2 milestone Jan 7, 2018
@tacaswell
Copy link
Member

That line of code goes back to one of the early commits (e34a333 in 2004) so we don't have a comment on why it was put there to begin with. @DietmarSchwertberger Any guesses as to why it was there?

@DietmarSchwertberger
Copy link
Contributor Author
DietmarSchwertberger commented Jan 7, 2018

This was probaby just out of habit.
For some events, Skip() is to be called to preserve the correct behaviour of the widget. E.g. when handling a character event for a TextCtrl the character would not be inserted without Skip.

For PAINT, the event is fully handled by the handler. With Skip, the handling is forwarded to the default handler which paints the grey background. No idea, why it worked at all. I would have expected that the whole widget is painted grey.

The documentation does not have a Skip:
https://wxpython.org/Phoenix/docs/html/wx.PaintEvent.html

P.S.: I have a feeling that it would make sense to change the whole implementation towards this:
https://wiki.wxpython.org/DoubleBufferedDrawing
https://github.com/wxWidgets/Phoenix/blob/master/demo/ScrolledWindow.py

The only thing that speaks against is the comment at GraphicsContextWx: "Creating a wxGraphicsContext seems to be fairly heavy, so these objects are cached based on the bitmap object that is passed in."
From looking at the wx sources, I don't see where this overhead would come from.

@tacaswell
Copy link
Member

Is this related to #10174 ? If so, could this be a change in the wx bindings?

@DietmarSchwertberger
Copy link
Contributor Author
DietmarSchwertberger commented Jan 8, 2018

This could be the same issue.
E.g. I see the problem with embedding_in_wx2.py but not with embedding_in_wx4.py.
So the errors are triggered by small changes.

wx did not change. I just checked the book from 2006. evt.Skip() was never supposed to be called. Not with direct paints and not with double-buffering.

@tacaswell tacaswell modified the milestones: v2.2, v2.1.2 Jan 8, 2018
@tacaswell tacaswell merged commit cc684c2 into matplotlib:master Jan 8, 2018
tacaswell added a commit that referenced this pull request Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0