diff options
author | Tal Einat <taleinat@gmail.com> | 2019-07-18 23:03:18 +0300 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2019-07-18 16:03:18 -0400 |
commit | e0a1f8fb5c60886dbddf1a3ccb5d47576bdd43e2 (patch) | |
tree | 6c5572560cdc1c0c9941edf11f08886a4d05243b /Lib/idlelib/codecontext.py | |
parent | 323842c2792a81e87917790506ec3457832c84b3 (diff) | |
download | cpython-git-e0a1f8fb5c60886dbddf1a3ccb5d47576bdd43e2.tar.gz |
bpo-33610: IDLE's code-context always shows current context immediately (GH-14821)
Eliminate delay of up to 100ms and accompanying visual artifact.
Fix bug of never showing context when hide and show.
Diffstat (limited to 'Lib/idlelib/codecontext.py')
-rw-r--r-- | Lib/idlelib/codecontext.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/idlelib/codecontext.py b/Lib/idlelib/codecontext.py index 9bd0fa1753..3103391cfe 100644 --- a/Lib/idlelib/codecontext.py +++ b/Lib/idlelib/codecontext.py @@ -63,10 +63,13 @@ class CodeContext: """ self.editwin = editwin self.text = editwin.text + self._reset() + + def _reset(self): self.context = None + self.t1 = None self.topvisible = 1 self.info = [(0, -1, "", False)] - self.t1 = None @classmethod def reload(cls): @@ -112,17 +115,17 @@ class CodeContext: padx=padx, border=border, relief=SUNKEN, state='disabled') self.update_highlight_colors() self.context.bind('<ButtonRelease-1>', self.jumptoline) + # Get the current context and initiate the recurring update event. + self.timer_event() # Pack the context widget before and above the text_frame widget, # thus ensuring that it will appear directly above text_frame. self.context.pack(side=TOP, fill=X, expand=False, before=self.editwin.text_frame) menu_status = 'Hide' - self.t1 = self.text.after(self.UPDATEINTERVAL, self.timer_event) else: self.context.destroy() - self.context = None self.text.after_cancel(self.t1) - self.t1 = None + self._reset() menu_status = 'Show' self.editwin.update_menu_label(menu='options', index='* Code Context', label=f'{menu_status} Code Context') |