Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f358b2

Browse files
committed
More wx cleanup.
1) math.ceil() returns an int on Py3. 2) Window.SetInitialSize and Window.IsShownOnScreen are documented in the wx API; it seems overkill to try to workaround their possible absence (that code was present from the very beginning of the git history). 3) the macros attribute is unused since 7499f7c (2004).
1 parent ca32c2d commit 6f358b2

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

doc/api/next_api_changes/2018-02-15-AL-deprecations.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ The following functions and classes are deprecated:
66
``get_realpath_and_stat``),
77
- ``cbook.is_numlike`` (use ``isinstance(..., numbers.Number)`` instead),
88
- ``mathtext.unichr_safe`` (use ``chr`` instead),
9+
- ``FigureCanvasWx.macros``,

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
should be included with this source code.
1414
1515
"""
16-
from __future__ import (absolute_import, division, print_function,
17-
unicode_literals)
1816

1917
import six
2018

@@ -627,30 +625,11 @@ def __init__(self, parent, id, figure):
627625
# Set preferred window size hint - helps the sizer (if one is
628626
# connected)
629627
l, b, w, h = figure.bbox.bounds
630-
w = int(math.ceil(w))
631-
h = int(math.ceil(h))
628+
w = math.ceil(w)
629+
h = math.ceil(h)
632630

633631
wx.Panel.__init__(self, parent, id, size=wx.Size(w, h))
634632

635-
def do_nothing(*args, **kwargs):
636-
warnings.warn(
637-
"could not find a setinitialsize function for backend_wx; "
638-
"please report your wxpython version=%s "
639-
"to the matplotlib developers list" %
640-
wxc.backend_version)
641-
pass
642-
643-
# try to find the set size func across wx versions
644-
try:
645-
getattr(self, 'SetInitialSize')
646-
except AttributeError:
647-
self.SetInitialSize = getattr(self, 'SetBestFittingSize',
648-
do_nothing)
649-
650-
if not hasattr(self, 'IsShownOnScreen'):
651-
self.IsShownOnScreen = getattr(self, 'IsVisible',
652-
lambda *args: True)
653-
654633
# Create the drawing bitmap
655634
self.bitmap = wxc.EmptyBitmap(w, h)
656635
DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self)
@@ -682,7 +661,10 @@ def do_nothing(*args, **kwargs):
682661
self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker.
683662
self.SetBackgroundColour(wx.WHITE)
684663

685-
self.macros = {} # dict from wx id to seq of macros
664+
@property
665+
@cbook.deprecated("3.0")
666+
def macros(self):
667+
return {}
686668

687669
def Destroy(self, *args, **kwargs):
688670
wx.Panel.Destroy(self, *args, **kwargs)
@@ -1098,8 +1080,8 @@ def _print_image(self, filename, filetype, *args, **kwargs):
10981080
origBitmap = self.bitmap
10991081

11001082
l, b, width, height = self.figure.bbox.bounds
1101-
width = int(math.ceil(width))
1102-
height = int(math.ceil(height))
1083+
width = math.ceil(width)
1084+
height = math.ceil(height)
11031085

11041086
self.bitmap = wxc.EmptyBitmap(width, height)
11051087

0 commit comments

Comments
 (0)