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

Skip to content

Commit 48da3f1

Browse files
fix PEP78, rename help->help_entries; if a help dialog is already open, just raise it
1 parent 31e32dd commit 48da3f1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/matplotlib/backend_tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,6 @@ def _get_help_html(self):
10631063
"<tbody>".join(rows[1:]) + "</tbody></table>")
10641064

10651065

1066-
10671066
default_tools = {'home': ToolHome, 'back': ToolBack, 'forward': ToolForward,
10681067
'zoom': ToolZoom, 'pan': ToolPan,
10691068
'subplots': 'ToolConfigureSubplots',

lib/matplotlib/backends/backend_wx.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,8 @@ def remove_rubberband(self, dc=None):
18261826
self._rect = None
18271827

18281828

1829-
class _TableDialog(wx.Dialog):
1830-
def __init__(self, parent, help, title="Help"):
1829+
class _HelpDialog(wx.Dialog):
1830+
def __init__(self, parent, help_entries, title="Help"):
18311831
wx.Dialog.__init__(self, parent, title=title,
18321832
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
18331833

@@ -1836,7 +1836,7 @@ def __init__(self, parent, help, title="Help"):
18361836
# create and add the entries
18371837
widths = [100, 140, 300]
18381838
bold = self.GetFont().MakeBold()
1839-
for r, row in enumerate(help):
1839+
for r, row in enumerate(help_entries):
18401840
for (col, width) in zip(row, widths):
18411841
label = wx.StaticText(self, label=col)
18421842
if r == 0:
@@ -1851,18 +1851,25 @@ def __init__(self, parent, help, title="Help"):
18511851
sizer.Fit(self)
18521852
self.Layout()
18531853
self.Bind(wx.EVT_CLOSE, self.OnClose)
1854+
OK.Bind(wx.EVT_BUTTON, self.OnClose)
18541855

18551856
def OnClose(self, evt):
1857+
HelpWx.dlg = None
18561858
self.DestroyLater()
18571859
evt.Skip()
18581860

18591861

18601862
class HelpWx(backend_tools.ToolHelpBase):
1863+
dlg = None
18611864
def trigger(self, *args):
1862-
help = [("Action","Shortcuts", "Description")]
1863-
help += self._get_help_entries()
1864-
dlg = _TableDialog(self.figure.canvas.GetTopLevelParent(), help)
1865-
dlg.Show()
1865+
if self.dlg:
1866+
self.dlg.Raise()
1867+
return
1868+
help_entries = [("Action", "Shortcuts", "Description")]
1869+
help_entries += self._get_help_entries()
1870+
self.dlg = _HelpDialog(self.figure.canvas.GetTopLevelParent(),
1871+
help_entries)
1872+
self.dlg.Show()
18661873

18671874

18681875
backend_tools.ToolSaveFigure = SaveFigureWx

0 commit comments

Comments
 (0)