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

Skip to content

Commit 1061e72

Browse files
committed
M AutoExpand.py
M Bindings.py M EditorWindow.py M PyShell.py M config-keys.def M configHandler.py M help.txt 1. Annotate the shell window with last restart boundary upon restart. 2. Provide a shell menu entry and hot key (F6) to jump to the last restart boundary. 3. Add a new shell menu feature to restart the shell. 4. Update the help menu to add these features. 5. Update the help menu to put text in same order as the menus. 6. Correct a capitalization inconsistency on the Edit menu: Expand Word 7. Rename the "Debug" menu to be "Shell": it's doing more now. 8. Rearrange the "Shell" menu to make the StackViewer entries adjacent. 9. Add a get_geometry method to EditorWindow, which may be of use in making window positions persisent. 10. Make <ctrl-v> the "Classic Windows" paste key. 11. Restore decorum on the Help menu by removing "Advice". As Guido said, things will never be the same. Thanks, David!
1 parent 506a224 commit 1061e72

7 files changed

Lines changed: 55 additions & 27 deletions

File tree

Lib/idlelib/AutoExpand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AutoExpand:
99

1010
menudefs = [
1111
('edit', [
12-
('E_xpand word', '<<expand-word>>'),
12+
('E_xpand Word', '<<expand-word>>'),
1313
]),
1414
]
1515

Lib/idlelib/Bindings.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@
5555
('run',[
5656
('Python Shell', '<<open-python-shell>>'),
5757
]),
58-
('debug', [
58+
('shell', [
59+
('_View Last Restart', '<<view-restart>>'),
60+
('_Restart Shell', '<<restart-shell>>'),
61+
None,
5962
('_Go to File/Line', '<<goto-file-line>>'),
60-
('_Stack Viewer', '<<open-stack-viewer>>'),
6163
('!_Debugger', '<<toggle-debugger>>'),
64+
('_Stack Viewer', '<<open-stack-viewer>>'),
6265
('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>' ),
6366
]),
64-
('settings', [
67+
('options', [
6568
('_Configure Idle...', '<<open-config-dialog>>'),
6669
None,
6770
('Revert to _Default Settings', '<<revert-all-settings>>'),
6871
]),
6972
('help', [
7073
('_IDLE Help...', '<<help>>'),
7174
('Python _Documentation...', '<<python-docs>>'),
72-
('_Advice...', '<<good-advice>>'),
7375
('View IDLE _Readme...', '<<view-readme>>'),
7476
None,
7577
('_About IDLE...', '<<about-idle>>'),

Lib/idlelib/EditorWindow.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
6060
'recent-files.lst')
6161
self.vbar = vbar = Scrollbar(top, name='vbar')
6262
self.text_frame = text_frame = Frame(top)
63+
self.width = idleConf.GetOption('main','EditorWindow','width')
6364
self.text = text = Text(text_frame, name='text', padx=5, wrap='none',
6465
foreground=idleConf.GetHighlight(currentTheme,
6566
'normal',fgBg='fg'),
@@ -71,7 +72,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
7172
'hilite',fgBg='bg'),
7273
insertbackground=idleConf.GetHighlight(currentTheme,
7374
'cursor',fgBg='fg'),
74-
width=idleConf.GetOption('main','EditorWindow','width'),
75+
width=self.width,
7576
height=idleConf.GetOption('main','EditorWindow','height') )
7677

7778
self.createmenubar()
@@ -84,7 +85,6 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
8485
text.bind("<<paste>>", self.paste)
8586
text.bind("<<center-insert>>", self.center_insert_event)
8687
text.bind("<<help>>", self.help_dialog)
87-
text.bind("<<good-advice>>", self.good_advice)
8888
text.bind("<<view-readme>>", self.view_readme)
8989
text.bind("<<python-docs>>", self.python_docs)
9090
text.bind("<<about-idle>>", self.about_dialog)
@@ -213,7 +213,7 @@ def wakeup(self):
213213
("edit", "_Edit"),
214214
("format", "F_ormat"),
215215
("run", "_Run"),
216-
("settings", "_Settings"),
216+
("options", "_Options"),
217217
("windows", "_Windows"),
218218
("help", "_Help"),
219219
]
@@ -277,9 +277,6 @@ def about_dialog(self, event=None):
277277
def config_dialog(self, event=None):
278278
configDialog.ConfigDialog(self.top,'Settings')
279279

280-
def good_advice(self, event=None):
281-
tkMessageBox.showinfo('Advice', "Don't Panic!", master=self.text)
282-
283280
def view_readme(self, event=None):
284281
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'README.txt')
285282
textView.TextViewer(self.top,'IDLEfork - README',fn)
@@ -666,6 +663,13 @@ def getlineno(self, mark="insert"):
666663
text = self.text
667664
return int(float(text.index(mark)))
668665

666+
def get_geometry(self):
667+
"Return (width, height, x, y)"
668+
geom = self.top.wm_geometry()
669+
m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
670+
tuple = (map(int, m.groups()))
671+
return tuple
672+
669673
def close_event(self, event):
670674
self.close()
671675

Lib/idlelib/PyShell.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ def restart_subprocess(self):
366366
self.spawn_subprocess()
367367
self.rpcclt.accept()
368368
self.transfer_path()
369+
# annotate restart in shell window and mark it
370+
console = self.tkconsole
371+
halfbar = ((int(console.width) - 16) // 2) * '='
372+
console.write(halfbar + ' RESTART ' + halfbar)
373+
console.text.mark_set("restart", "end-1c")
374+
console.text.mark_gravity("restart", "left")
369375
# restart remote debugger
370376
if debug:
371377
gui = RemoteDebugger.restart_subprocess_debugger(self.rpcclt)
@@ -652,8 +658,8 @@ class PyShell(OutputWindow):
652658
menu_specs = [
653659
("file", "_File"),
654660
("edit", "_Edit"),
655-
("debug", "_Debug"),
656-
("settings", "_Settings"),
661+
("shell", "_Shell"),
662+
("options", "_Options"),
657663
("windows", "_Windows"),
658664
("help", "_Help"),
659665
]
@@ -687,6 +693,8 @@ def __init__(self, flist=None):
687693
text.bind("<<toggle-debugger>>", self.toggle_debugger)
688694
text.bind("<<open-python-shell>>", self.flist.open_shell)
689695
text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
696+
text.bind("<<view-restart>>", self.view_restart_mark)
697+
text.bind("<<restart-shell>>", self.restart_shell)
690698
#
691699
self.save_stdout = sys.stdout
692700
self.save_stderr = sys.stderr
@@ -727,7 +735,7 @@ def set_debugger_indicator(self):
727735
db = self.interp.getdebugger()
728736
self.setvar("<<toggle-debugger>>", not not db)
729737

730-
def toggle_jit_stack_viewer( self, event=None):
738+
def toggle_jit_stack_viewer(self, event=None):
731739
pass # All we need is the variable
732740

733741
def close_debugger(self):
@@ -1024,6 +1032,14 @@ def open_stack_viewer(self, event=None):
10241032
from StackViewer import StackBrowser
10251033
sv = StackBrowser(self.root, self.flist)
10261034

1035+
def view_restart_mark(self, event=None):
1036+
self.text.see("iomark")
1037+
self.text.see("restart")
1038+
1039+
def restart_shell(self, event=None):
1040+
self.interp.restart_subprocess()
1041+
self.showprompt()
1042+
10271043
def showprompt(self):
10281044
self.resetoutput()
10291045
try:

Lib/idlelib/config-keys.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[IDLE Classic Windows]
1111
copy=<Control-Key-c>
1212
cut=<Control-Key-x>
13-
paste=<Control-Key-m>
13+
paste=<Control-Key-v>
1414
beginning-of-line= <Key-Home>
1515
center-insert=<Control-Key-l>
1616
close-all-windows=<Control-Key-q>
@@ -22,6 +22,7 @@ python-context-help=<Shift-Key-F1>
2222
history-next=<Alt-Key-n>
2323
history-previous=<Alt-Key-p>
2424
interrupt-execution=<Control-Key-c>
25+
view-restart=<Key-F6>
2526
open-class-browser=<Alt-Key-c>
2627
open-module=<Alt-Key-m>
2728
open-new-window=<Control-Key-n>
@@ -67,6 +68,7 @@ end-of-file=<Control-Key-d>
6768
history-next=<Alt-Key-n> <Meta-Key-n>
6869
history-previous=<Alt-Key-p> <Meta-Key-p>
6970
interrupt-execution=<Control-Key-c>
71+
view-restart=<Key-F6>
7072
open-class-browser=<Control-Key-x><Control-Key-b>
7173
open-module=<Control-Key-x><Control-Key-m>
7274
open-new-window=<Control-Key-x><Control-Key-n>
@@ -116,6 +118,7 @@ python-context-help=<Shift-Key-F1>
116118
history-next=<Control-Key-n>
117119
history-previous=<Control-Key-p>
118120
interrupt-execution=<Control-Key-c>
121+
view-restart=<Key-F6>
119122
open-class-browser=<Command-Key-b>
120123
open-module=<Command-Key-m>
121124
open-new-window=<Command-Key-n>

Lib/idlelib/configHandler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ def GetCoreKeys(self, keySetName=None):
508508
'<<history-next>>': ['<Alt-n>'],
509509
'<<history-previous>>': ['<Alt-p>'],
510510
'<<interrupt-execution>>': ['<Control-c>'],
511+
'<<view-restart>>': ['<F6>'],
511512
'<<open-class-browser>>': ['<Alt-c>'],
512513
'<<open-module>>': ['<Alt-m>'],
513514
'<<open-new-window>>': ['<Control-n>'],

Lib/idlelib/help.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[See end for ** TIPS ]
1+
[See end for ** TIPS on using IDLE]
22

33
Click on the dotted line at the top of a menu to "tear it off": a
44
separate window containing the menu is created.
@@ -11,7 +11,7 @@ File Menu:
1111
Open Module... -- open an existing module (searches sys.path)
1212
Class Browser -- show classes and methods in current file
1313
Path Browser -- show sys.path directories, modules, classes
14-
and methods
14+
and methods
1515
---
1616
Save -- save current window to the associated file (unsaved
1717
windows have a * before and after the window title)
@@ -64,7 +64,18 @@ Run Menu (only in Edit window):
6464
Check Module -- Run a syntax check on the module
6565
Run Script -- Execute the current file in the __main__ namespace
6666

67-
Settings Menu:
67+
Shell Menu (only in Shell window):
68+
69+
View Last Restart -- Scroll the shell window to the last restart
70+
Restart Shell -- Restart the interpreter with a fresh environment
71+
---
72+
Go to File/Line -- look around the insert point for a filename
73+
and linenumber, open the file, and show the line
74+
Debugger (toggle) -- Run commands in the shell under the debugger
75+
Stack Viewer -- show the stack traceback of the last exception
76+
Auto-open Stack Viewer (toggle) -- Open stack viewer on traceback
77+
78+
Options Menu:
6879

6980
Configure IDLE -- Open a configuration dialog. Fonts, indentation,
7081
keybindings, and color themes may be altered.
@@ -81,20 +92,11 @@ Windows Menu:
8192
select one to bring it to the foreground (deiconifying it if
8293
necessary).
8394

84-
Debug Menu (in the Python Shell window only):
85-
86-
Go to File/Line -- look around the insert point for a filename
87-
and linenumber, open the file, and show the line
88-
Stack Viewer -- show the stack traceback of the last exception
89-
Debugger (toggle) -- Run commands in the shell under the debugger
90-
Auto-open Stack Viewer (toggle) -- Open stack viewer on traceback
91-
9295
Help Menu:
9396

9497
IDLE Help -- Display this file
9598
Python Documentation -- Access local Python documentation, if
9699
installed. Otherwise access python.org.
97-
Advice -- Emergency Only!
98100
IDLE Readme -- Background discussion and change details
99101
---
100102
About IDLE --- Version, copyright, license, credits

0 commit comments

Comments
 (0)