Skip to content

Commit 99d37a0

Browse files
bpo-33610: Edit idlelib.codecontext (GH-23773) (GH-23775)
Add sentence to module docstring and import tkinter items. (cherry picked from commit 6f79e60) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent 9d1fff1 commit 99d37a0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/idlelib/codecontext.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
enclosing block. The number of hint lines is determined by the maxlines
88
variable in the codecontext section of config-extensions.def. Lines which do
99
not open blocks are not shown in the context hints pane.
10+
11+
For EditorWindows, <<toggle-code-context>> is bound to CodeContext(self).
12+
toggle_code_context_event.
1013
"""
1114
import re
1215
from sys import maxsize as INFINITY
1316

14-
import tkinter
17+
from tkinter import Frame, Text, TclError
1518
from tkinter.constants import NSEW, SUNKEN
1619

1720
from idlelib.config import idleConf
@@ -83,7 +86,7 @@ def __del__(self):
8386
if self.t1 is not None:
8487
try:
8588
self.text.after_cancel(self.t1)
86-
except tkinter.TclError: # pragma: no cover
89+
except TclError: # pragma: no cover
8790
pass
8891
self.t1 = None
8992

@@ -111,7 +114,7 @@ def toggle_code_context_event(self, event=None):
111114
padx += widget.tk.getint(info['padx'])
112115
padx += widget.tk.getint(widget.cget('padx'))
113116
border += widget.tk.getint(widget.cget('border'))
114-
context = self.context = tkinter.Text(
117+
context = self.context = Text(
115118
self.editwin.text_frame,
116119
height=1,
117120
width=1, # Don't request more than we get.
@@ -127,7 +130,7 @@ def toggle_code_context_event(self, event=None):
127130

128131
line_number_colors = idleConf.GetHighlight(idleConf.CurrentTheme(),
129132
'linenumber')
130-
self.cell00 = tkinter.Frame(self.editwin.text_frame,
133+
self.cell00 = Frame(self.editwin.text_frame,
131134
bg=line_number_colors['background'])
132135
self.cell00.grid(row=0, column=0, sticky=NSEW)
133136
menu_status = 'Hide'
@@ -221,7 +224,7 @@ def jumptoline(self, event=None):
221224
"""
222225
try:
223226
self.context.index("sel.first")
224-
except tkinter.TclError:
227+
except TclError:
225228
lines = len(self.info)
226229
if lines == 1: # No context lines are showing.
227230
newtop = 1

0 commit comments

Comments
 (0)