summaryrefslogtreecommitdiff
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2012-02-05 15:14:20 -0500
committerTerry Jan Reedy <tjreedy@udel.edu>2012-02-05 15:14:20 -0500
commite91e7637bb2d7723b95cd7d3b8f581aff39d70f2 (patch)
treeb14166161f607d793ee84bffc0c21f9e0a7fd83b /Lib/idlelib/EditorWindow.py
parenta77aa69870aad71c9cfce10fbca5f1e25cb2bb95 (diff)
downloadcpython-git-e91e7637bb2d7723b95cd7d3b8f581aff39d70f2.tar.gz
Issue 964437 Make IDLE help window non-modal.
Patch by Guilherme Polo and Roger Serwy.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index f47a9c1348..6a01db0125 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -63,6 +63,50 @@ def _find_module(fullname, path=None):
descr = os.path.splitext(filename)[1], None, imp.PY_SOURCE
return file, filename, descr
+
+class HelpDialog(object):
+
+ def __init__(self):
+ self.parent = None # parent of help window
+ self.dlg = None # the help window iteself
+
+ def display(self, parent, near=None):
+ """ Display the help dialog.
+
+ parent - parent widget for the help window
+
+ near - a Toplevel widget (e.g. EditorWindow or PyShell)
+ to use as a reference for placing the help window
+ """
+ if self.dlg is None:
+ self.show_dialog(parent)
+ if near:
+ self.nearwindow(near)
+
+ def show_dialog(self, parent):
+ self.parent = parent
+ fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
+ self.dlg = dlg = textView.view_file(parent,'Help',fn, modal=False)
+ dlg.bind('<Destroy>', self.destroy, '+')
+
+ def nearwindow(self, near):
+ # Place the help dialog near the window specified by parent.
+ # Note - this may not reposition the window in Metacity
+ # if "/apps/metacity/general/disable_workarounds" is enabled
+ dlg = self.dlg
+ geom = (near.winfo_rootx() + 10, near.winfo_rooty() + 10)
+ dlg.withdraw()
+ dlg.geometry("=+%d+%d" % geom)
+ dlg.deiconify()
+ dlg.lift()
+
+ def destroy(self, ev=None):
+ self.dlg = None
+ self.parent = None
+
+helpDialog = HelpDialog() # singleton instance
+
+
class EditorWindow(object):
from idlelib.Percolator import Percolator
from idlelib.ColorDelegator import ColorDelegator
@@ -453,8 +497,11 @@ class EditorWindow(object):
configDialog.ConfigDialog(self.top,'Settings')
def help_dialog(self, event=None):
- fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
- textView.view_file(self.top,'Help',fn)
+ if self.root:
+ parent = self.root
+ else:
+ parent = self.top
+ helpDialog.display(parent, near=self.top)
def python_docs(self, event=None):
if sys.platform[:3] == 'win':