From dd562095cb5b881c1d96dc4a63d4275bf3f642c9 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 5 Nov 2017 22:14:24 -0800 Subject: [PATCH 1/2] Small cleanups. --- lib/matplotlib/backends/backend_qt5.py | 16 ++++++---------- lib/matplotlib/backends/backend_tkagg.py | 1 - 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 6d4546644aa3..07439093db48 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -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 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 @@ -256,6 +248,10 @@ def __init__(self, figure): # needed. self._dpi_ratio_prev = None + self.setMouseTracking(True) + # Key auto-repeat enabled by default + self._keyautorepeat = True + @property def _dpi_ratio(self): # Not available on Qt4 or some older Qt5. diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 70b06274c00d..da8773fac277 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -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): From d5d553a050890ea9c754438aaa1baa8d426ac62a Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 5 Nov 2017 22:21:43 -0800 Subject: [PATCH 2/2] 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. --- examples/user_interfaces/embedding_in_wx3_sgskip.py | 4 ---- lib/matplotlib/backends/backend_qt5.py | 3 +++ lib/matplotlib/backends/backend_tkagg.py | 4 ++-- lib/matplotlib/backends/backend_wx.py | 11 ++--------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/examples/user_interfaces/embedding_in_wx3_sgskip.py b/examples/user_interfaces/embedding_in_wx3_sgskip.py index 9368b2917438..c1aca8b6d144 100644 --- a/examples/user_interfaces/embedding_in_wx3_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx3_sgskip.py @@ -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): diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 07439093db48..e3ac5467508e 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -252,6 +252,9 @@ def __init__(self, figure): # 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. diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index da8773fac277..58d171f0d737 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -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) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 49ba3e87f9f2..7be2117f483e 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -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 @@ -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. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy