|
20 | 20 | StatusbarBase) |
21 | 21 | from matplotlib.backend_bases import _has_pil |
22 | 22 |
|
| 23 | +from matplotlib import cbook, rcParams, backend_tools |
23 | 24 | from matplotlib._pylab_helpers import Gcf |
| 25 | +from matplotlib.backend_managers import ToolManager |
24 | 26 | from matplotlib.figure import Figure |
25 | 27 | from matplotlib.path import Path |
26 | 28 | from matplotlib.transforms import Affine2D |
27 | 29 | from matplotlib.widgets import SubplotTool |
28 | | -from matplotlib.backend_managers import ToolManager |
29 | | -from matplotlib import cbook, rcParams, backend_tools |
30 | 30 |
|
31 | 31 | import wx |
32 | 32 |
|
|
38 | 38 | # traceback is performed, and pdb activated, for all uncaught exceptions in |
39 | 39 | # this case |
40 | 40 | _DEBUG = 5 |
41 | | -if _DEBUG < 5: |
42 | | - import traceback |
43 | | - import pdb |
44 | 41 | _DEBUG_lvls = {1: 'Low ', 2: 'Med ', 3: 'High', 4: 'Error'} |
45 | 42 |
|
46 | 43 |
|
47 | 44 | def DEBUG_MSG(string, lvl=3, o=None): |
48 | 45 | if lvl >= _DEBUG: |
49 | | - cls = o.__class__ |
50 | | - # Jeremy, often times the commented line won't print but the |
51 | | - # one below does. I think WX is redefining stderr, damned |
52 | | - # beast |
53 | | - # print("%s- %s in %s" % (_DEBUG_lvls[lvl], string, cls), |
54 | | - # file=sys.stderr) |
55 | | - print("%s- %s in %s" % (_DEBUG_lvls[lvl], string, cls)) |
| 46 | + print(f"{_DEBUG_lvls[lvl]}- {string} in {type(o)}") |
56 | 47 |
|
57 | 48 |
|
| 49 | +@cbook.deprecated("3.1") |
58 | 50 | def debug_on_error(type, value, tb): |
59 | 51 | """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)""" |
| 52 | + import pdb |
| 53 | + import traceback |
60 | 54 | traceback.print_exception(type, value, tb) |
61 | 55 | print() |
62 | | - pdb.pm() # jdh uncomment |
| 56 | + pdb.pm() |
63 | 57 |
|
64 | 58 |
|
| 59 | +@cbook.deprecated("3.1") |
65 | 60 | class fake_stderr(object): |
66 | 61 | """ |
67 | 62 | Wx does strange things with stderr, as it makes the assumption that |
@@ -96,6 +91,7 @@ def error_msg_wx(msg, parent=None): |
96 | 91 | return None |
97 | 92 |
|
98 | 93 |
|
| 94 | +@cbook.deprecated("3.1") |
99 | 95 | def raise_msg_to_str(msg): |
100 | 96 | """msg is a return arg from a raise. Join with new lines.""" |
101 | 97 | if not isinstance(msg, str): |
@@ -1091,22 +1087,16 @@ def _print_image(self, filename, filetype, *args, **kwargs): |
1091 | 1087 | image = self.bitmap.ConvertToImage() |
1092 | 1088 | image.SetOption(wx.IMAGE_OPTION_QUALITY, str(jpeg_quality)) |
1093 | 1089 |
|
1094 | | - # Now that we have rendered into the bitmap, save it |
1095 | | - # to the appropriate file type and clean up |
| 1090 | + # Now that we have rendered into the bitmap, save it to the appropriate |
| 1091 | + # file type and clean up. |
1096 | 1092 | if isinstance(filename, str): |
1097 | 1093 | if not image.SaveFile(filename, filetype): |
1098 | | - DEBUG_MSG('print_figure() file save error', 4, self) |
1099 | | - raise RuntimeError( |
1100 | | - 'Could not save figure to %s\n' % |
1101 | | - (filename)) |
| 1094 | + raise RuntimeError(f'Could not save figure to {filename}') |
1102 | 1095 | elif cbook.is_writable_file_like(filename): |
1103 | 1096 | if not isinstance(image, wx.Image): |
1104 | 1097 | image = image.ConvertToImage() |
1105 | 1098 | if not image.SaveStream(filename, filetype): |
1106 | | - DEBUG_MSG('print_figure() file save error', 4, self) |
1107 | | - raise RuntimeError( |
1108 | | - 'Could not save figure to %s\n' % |
1109 | | - (filename)) |
| 1099 | + raise RuntimeError(f'Could not save figure to {filename}') |
1110 | 1100 |
|
1111 | 1101 | # Restore everything to normal |
1112 | 1102 | self.bitmap = origBitmap |
@@ -1316,6 +1306,7 @@ def _set_frame_icon(frame): |
1316 | 1306 | frame.SetIcons(bundle) |
1317 | 1307 |
|
1318 | 1308 |
|
| 1309 | +@cbook.deprecated("3.1") |
1319 | 1310 | class MenuButtonWx(wx.Button): |
1320 | 1311 | """ |
1321 | 1312 | wxPython does not permit a menu to be incorporated directly into a toolbar. |
@@ -1393,7 +1384,7 @@ def updateAxes(self, maxAxis): |
1393 | 1384 | """Ensures that there are entries for max_axis axes in the menu |
1394 | 1385 | (selected by default).""" |
1395 | 1386 | if maxAxis > len(self._axisId): |
1396 | | - for i in range(len(self._axisId) + 1, maxAxis + 1, 1): |
| 1387 | + for i in range(len(self._axisId) + 1, maxAxis + 1): |
1397 | 1388 | menuId = wx.NewId() |
1398 | 1389 | self._axisId.append(menuId) |
1399 | 1390 | self._menu.Append(menuId, "Axis %d" % i, |
@@ -1638,16 +1629,10 @@ class StatusBarWx(wx.StatusBar): |
1638 | 1629 | def __init__(self, parent, *args, **kwargs): |
1639 | 1630 | wx.StatusBar.__init__(self, parent, -1) |
1640 | 1631 | self.SetFieldsCount(2) |
1641 | | - self.SetStatusText("None", 1) |
1642 | | - # self.SetStatusText("Measurement: None", 2) |
1643 | | - # self.Reposition() |
1644 | 1632 |
|
1645 | 1633 | def set_function(self, string): |
1646 | 1634 | self.SetStatusText("%s" % string, 1) |
1647 | 1635 |
|
1648 | | - # def set_measurement(self, string): |
1649 | | - # self.SetStatusText("Measurement: %s" % string, 2) |
1650 | | - |
1651 | 1636 |
|
1652 | 1637 | # tools for matplotlib.backend_managers.ToolManager: |
1653 | 1638 |
|
@@ -1956,6 +1941,7 @@ def trigger(self, *args, **kwargs): |
1956 | 1941 |
|
1957 | 1942 | # < Additions for printing support: Matt Newville |
1958 | 1943 |
|
| 1944 | +@cbook.deprecated("3.1") |
1959 | 1945 | class PrintoutWx(wx.Printout): |
1960 | 1946 | """ |
1961 | 1947 | Simple wrapper around wx Printout class -- all the real work |
@@ -2037,7 +2023,6 @@ def OnPrintPage(self, page): |
2037 | 2023 | self.canvas.figure.dpi = fig_dpi |
2038 | 2024 | self.canvas.draw() |
2039 | 2025 | return True |
2040 | | -# > |
2041 | 2026 |
|
2042 | 2027 |
|
2043 | 2028 | @_Backend.export |
|
0 commit comments