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
b3418889
Commit
b3418889
authored
Oct 13, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new command, "Open module". You select or type a module name,
and it opens the source.
parent
5af7a72d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
Tools/idle/Bindings.py
Tools/idle/Bindings.py
+2
-0
Tools/idle/EditorWindow.py
Tools/idle/EditorWindow.py
+31
-0
No files found.
Tools/idle/Bindings.py
View file @
b3418889
...
...
@@ -57,6 +57,8 @@ emacs_bindings = [
"<<open-new-window>>"
,
"<Control-x><Control-n>"
),
(
"file"
,
"Open..."
,
"C-x C-f"
,
"<<open-window-from-file>>"
,
"<Control-x><Control-f>"
),
(
"file"
,
"Open module..."
,
"C-x C-m"
,
"<<open-module>>"
,
"<Control-x><Control-m>"
),
(
"file"
,
None
,
None
),
(
"file"
,
"Save"
,
"C-x C-s"
,
...
...
Tools/idle/EditorWindow.py
View file @
b3418889
import
sys
import
os
import
string
import
imp
from
Tkinter
import
*
import
tkSimpleDialog
import
tkMessageBox
about_title
=
"About IDLE"
...
...
@@ -42,6 +44,7 @@ class EditorWindow:
self
.
text
.
bind
(
"<<center-insert>>"
,
self
.
center_insert_event
)
self
.
text
.
bind
(
"<<help>>"
,
self
.
help_dialog
)
self
.
text
.
bind
(
"<<about-idle>>"
,
self
.
about_dialog
)
self
.
text
.
bind
(
"<<open-module>>"
,
self
.
open_module
)
vbar
[
'command'
]
=
text
.
yview
vbar
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
...
...
@@ -98,6 +101,34 @@ class EditorWindow:
def
help_dialog
(
self
,
event
=
None
):
from
HelpWindow
import
HelpWindow
HelpWindow
(
root
=
self
.
root
)
def
open_module
(
self
,
event
=
None
):
try
:
name
=
self
.
text
.
get
(
"sel.first"
,
"sel.last"
)
except
TclError
:
name
=
""
else
:
name
=
string
.
strip
(
name
)
if
not
name
:
name
=
tkSimpleDialog
.
askstring
(
"Module"
,
"Module name:"
,
parent
=
self
.
text
)
if
name
:
name
=
string
.
strip
(
name
)
if
not
name
:
return
try
:
(
f
,
file
,
(
suffix
,
mode
,
type
))
=
imp
.
find_module
(
name
)
except
ImportError
,
msg
:
tkMessageBox
.
showerror
(
"Import error"
,
str
(
msg
),
parent
=
self
.
text
)
return
if
type
!=
imp
.
PY_SOURCE
:
tkMessageBox
.
showerror
(
"Unsupported type"
,
"%s is not a source module"
%
name
,
parent
=
self
.
text
)
return
if
f
:
f
.
close
()
self
.
flist
.
open
(
file
,
self
)
def
gotoline
(
self
,
lineno
):
if
lineno
is
not
None
and
lineno
>
0
:
...
...
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