Skip to content

Set widget background color to white. #9698

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
merged 2 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions examples/user_interfaces/embedding_in_wx3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ def OnWhiz(self, evt):

self.canvas.draw()

def onEraseBackground(self, evt):
# this is supposed to prevent redraw flicker on some X servers...
pass


class MyApp(wx.App):
def OnInit(self):
Expand Down
19 changes: 9 additions & 10 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,12 @@ def _update_figure_dpi(self):
@_allow_super_init
def __init__(self, figure):
_create_qApp()
figure._original_dpi = figure.dpi

super(FigureCanvasQT, self).__init__(figure=figure)

figure._original_dpi = figure.dpi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the super chain no longer use _original_dpi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT the only places it is accessed are _update_figure_dpi (which is called later) and print_figure (which is irrelevant here).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this got sorted out as part of the initial draw / re-entrant paint fix.

self.figure = figure
self._update_figure_dpi()

w, h = self.get_width_height()
self.resize(w, h)

self.setMouseTracking(True)
# Key auto-repeat enabled by default
self._keyautorepeat = True

self.resize(*self.get_width_height())
# In cases with mixed resolution displays, we need to be careful if the
# dpi_ratio changes - in this case we need to resize the canvas
# accordingly. We could watch for screenChanged events from Qt, but
Expand All @@ -256,6 +248,13 @@ def __init__(self, figure):
# needed.
self._dpi_ratio_prev = None

self.setMouseTracking(True)
# Key auto-repeat enabled by default
self._keyautorepeat = True

palette = QtGui.QPalette(QtCore.Qt.white)
self.setPalette(palette)

@property
def _dpi_ratio(self):
# Not available on Qt4 or some older Qt5.
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/backends/backend_tkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def __init__(self, figure, master=None, resize_callback=None):
t1,t2,w,h = self.figure.bbox.bounds
w, h = int(w), int(h)
self._tkcanvas = Tk.Canvas(
master=master, width=w, height=h, borderwidth=0,
highlightthickness=0)
master=master, background="white",
width=w, height=h, borderwidth=0, highlightthickness=0)
self._tkphoto = Tk.PhotoImage(
master=self._tkcanvas, width=w, height=h)
self._tkcanvas.create_image(w//2, h//2, image=self._tkphoto)
Expand Down Expand Up @@ -661,7 +661,6 @@ class NavigationToolbar2TkAgg(NavigationToolbar2, Tk.Frame):
def __init__(self, canvas, window):
self.canvas = canvas
self.window = window
self._idle = True
NavigationToolbar2.__init__(self, canvas)

def destroy(self, *args):
Expand Down
11 changes: 2 additions & 9 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ def do_nothing(*args, **kwargs):
self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost)
self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost)

# Reduce flicker.
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker.
self.SetBackgroundColour(wx.WHITE)

self.macros = {} # dict from wx id to seq of macros

Expand Down Expand Up @@ -941,13 +941,6 @@ def _onPaint(self, evt):
self.gui_repaint(drawDC=drawDC)
evt.Skip()

def _onEraseBackground(self, evt):
"""
Called when window is redrawn; since we are blitting the entire
image, we can leave this blank to suppress flicker.
"""
pass

def _onSize(self, evt):
"""
Called when wxEventSize is generated.
Expand Down