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

Skip to content

Commit 8818ee3

Browse files
fix handling of the global reference to the open dialog; add comments to make clear
1 parent 48da3f1 commit 8818ee3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,22 +1854,24 @@ def __init__(self, parent, help_entries, title="Help"):
18541854
OK.Bind(wx.EVT_BUTTON, self.OnClose)
18551855

18561856
def OnClose(self, evt):
1857-
HelpWx.dlg = None
1857+
HelpWx.dlg = None # remove global reference
18581858
self.DestroyLater()
18591859
evt.Skip()
18601860

18611861

18621862
class HelpWx(backend_tools.ToolHelpBase):
1863-
dlg = None
1863+
dlg = None # a reference to the opened dialog, to avoid more than one
18641864
def trigger(self, *args):
1865-
if self.dlg:
1866-
self.dlg.Raise()
1865+
if HelpWx.dlg:
1866+
# previous dialog is still open
1867+
HelpWx.dlg.Raise()
18671868
return
1869+
# create new dialog and keep a reference
18681870
help_entries = [("Action", "Shortcuts", "Description")]
18691871
help_entries += self._get_help_entries()
1870-
self.dlg = _HelpDialog(self.figure.canvas.GetTopLevelParent(),
1871-
help_entries)
1872-
self.dlg.Show()
1872+
HelpWx.dlg = _HelpDialog(self.figure.canvas.GetTopLevelParent(),
1873+
help_entries)
1874+
HelpWx.dlg.Show()
18731875

18741876

18751877
backend_tools.ToolSaveFigure = SaveFigureWx

0 commit comments

Comments
 (0)