Skip to content

Commit d5d553a

Browse files
committed
Set widget background to white.
The background color of the widget can be seen by setting a transparent figure facecolor, e.g. from pylab import * rcParams["figure.facecolor"] = (0, 0, 0, 0); gca(); show() The goal is to ultimately replace setting `savefig.transparent` by `figure.facecolor = (0, 0, 0, 0)`. As far as I can tell, gtk3 already defaults to a white background. Not sure what the situation is on OSX.
1 parent dd56209 commit d5d553a

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

examples/user_interfaces/embedding_in_wx3_sgskip.py

-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ def OnWhiz(self, evt):
9999

100100
self.canvas.draw()
101101

102-
def onEraseBackground(self, evt):
103-
# this is supposed to prevent redraw flicker on some X servers...
104-
pass
105-
106102

107103
class MyApp(wx.App):
108104
def OnInit(self):

lib/matplotlib/backends/backend_qt5.py

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ def __init__(self, figure):
252252
# Key auto-repeat enabled by default
253253
self._keyautorepeat = True
254254

255+
palette = QtGui.QPalette(QtCore.Qt.white)
256+
self.setPalette(palette)
257+
255258
@property
256259
def _dpi_ratio(self):
257260
# Not available on Qt4 or some older Qt5.

lib/matplotlib/backends/backend_tkagg.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def __init__(self, figure, master=None, resize_callback=None):
176176
t1,t2,w,h = self.figure.bbox.bounds
177177
w, h = int(w), int(h)
178178
self._tkcanvas = Tk.Canvas(
179-
master=master, width=w, height=h, borderwidth=0,
180-
highlightthickness=0)
179+
master=master, background="white",
180+
width=w, height=h, borderwidth=0, highlightthickness=0)
181181
self._tkphoto = Tk.PhotoImage(
182182
master=self._tkcanvas, width=w, height=h)
183183
self._tkcanvas.create_image(w//2, h//2, image=self._tkphoto)

lib/matplotlib/backends/backend_wx.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ def do_nothing(*args, **kwargs):
684684
self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost)
685685
self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost)
686686

687-
# Reduce flicker.
688-
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
687+
self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker.
688+
self.SetBackgroundColour(wx.WHITE)
689689

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

@@ -941,13 +941,6 @@ def _onPaint(self, evt):
941941
self.gui_repaint(drawDC=drawDC)
942942
evt.Skip()
943943

944-
def _onEraseBackground(self, evt):
945-
"""
946-
Called when window is redrawn; since we are blitting the entire
947-
image, we can leave this blank to suppress flicker.
948-
"""
949-
pass
950-
951944
def _onSize(self, evt):
952945
"""
953946
Called when wxEventSize is generated.

0 commit comments

Comments
 (0)