Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e91e7637
Commit
e91e7637
authored
Feb 05, 2012
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 964437 Make IDLE help window non-modal.
Patch by Guilherme Polo and Roger Serwy.
parent
a77aa698
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
11 deletions
+67
-11
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+49
-2
Lib/idlelib/textView.py
Lib/idlelib/textView.py
+15
-9
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/idlelib/EditorWindow.py
View file @
e91e7637
...
...
@@ -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'
:
...
...
Lib/idlelib/textView.py
View file @
e91e7637
...
...
@@ -9,7 +9,7 @@ class TextViewer(Toplevel):
"""A simple text viewer dialog for IDLE
"""
def
__init__
(
self
,
parent
,
title
,
text
):
def
__init__
(
self
,
parent
,
title
,
text
,
modal
=
True
):
"""Show the given text in a scrollable window with a 'close' button
"""
...
...
@@ -24,8 +24,6 @@ class TextViewer(Toplevel):
self
.
CreateWidgets
()
self
.
title
(
title
)
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
Ok
)
self
.
parent
=
parent
self
.
textView
.
focus_set
()
...
...
@@ -34,6 +32,10 @@ class TextViewer(Toplevel):
self
.
bind
(
'<Escape>'
,
self
.
Ok
)
#dismiss dialog
self
.
textView
.
insert
(
0.0
,
text
)
self
.
textView
.
config
(
state
=
DISABLED
)
if
modal
:
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
wait_window
()
def
CreateWidgets
(
self
):
...
...
@@ -57,10 +59,10 @@ class TextViewer(Toplevel):
self
.
destroy
()
def
view_text
(
parent
,
title
,
text
):
TextViewer
(
parent
,
title
,
text
)
def
view_text
(
parent
,
title
,
text
,
modal
=
True
):
return
TextViewer
(
parent
,
title
,
text
,
modal
)
def
view_file
(
parent
,
title
,
filename
,
encoding
=
None
):
def
view_file
(
parent
,
title
,
filename
,
encoding
=
None
,
modal
=
True
):
try
:
with
open
(
filename
,
'r'
,
encoding
=
encoding
)
as
file
:
contents
=
file
.
read
()
...
...
@@ -70,7 +72,7 @@ def view_file(parent, title, filename, encoding=None):
message
=
'Unable to load file %r .'
%
filename
,
parent
=
parent
)
else
:
return
view_text
(
parent
,
title
,
contents
)
return
view_text
(
parent
,
title
,
contents
,
modal
)
if
__name__
==
'__main__'
:
...
...
@@ -85,6 +87,10 @@ if __name__ == '__main__':
btn2
=
Button
(
root
,
text
=
'view_file'
,
command
=
lambda
:
view_file
(
root
,
'view_file'
,
filename
))
btn2
.
pack
(
side
=
LEFT
)
btn3
=
Button
(
root
,
text
=
'nonmodal view_text'
,
command
=
lambda
:
view_text
(
root
,
'nonmodal view_text'
,
text
,
modal
=
False
))
btn3
.
pack
(
side
=
LEFT
)
close
=
Button
(
root
,
text
=
'Close'
,
command
=
root
.
destroy
)
close
.
pack
(
side
=
RIGHT
)
root
.
mainloop
()
Misc/NEWS
View file @
e91e7637
...
...
@@ -113,6 +113,9 @@ Core and Builtins
Library
-------
- Issue #964437 Make IDLE help window non-modal.
Patch by Guilherme Polo and Roger Serwy.
- Issue #2945: Make the distutils upload command aware of bdist_rpm products.
- Issue #13933: IDLE auto-complete did not work with some imported
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment