diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-03-09 23:45:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 23:45:19 (GMT) |
commit | cadfe52a006abb46ea0948c6ae2e006064b4a091 (patch) | |
tree | 046e81a90a6663a3eb3ae4612a9825464077e6a8 /Lib/idlelib/query.py | |
parent | 5854d451cb35ac38bc07b95afeb077e8a35d5c7d (diff) | |
download | cpython-cadfe52a006abb46ea0948c6ae2e006064b4a091.zip cpython-cadfe52a006abb46ea0948c6ae2e006064b4a091.tar.gz cpython-cadfe52a006abb46ea0948c6ae2e006064b4a091.tar.bz2 |
bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
Replace tkinter tkSimpleDialog.askinteger with a standard IDLE query dialog.
The new box checks for positivity before returning.
(cherry picked from commit 363fab83b8a0e6d924c7a7c577feec6a2812bb8c)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/query.py')
-rw-r--r-- | Lib/idlelib/query.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/idlelib/query.py b/Lib/idlelib/query.py index 57616de..2a88530 100644 --- a/Lib/idlelib/query.py +++ b/Lib/idlelib/query.py @@ -223,6 +223,22 @@ class ModuleName(Query): return file_path +class Goto(Query): + "Get a positive line number for editor Go To Line." + # Used in editor.EditorWindow.goto_line_event. + + def entry_ok(self): + try: + lineno = int(self.entry.get()) + except ValueError: + self.showerror('not a base 10 integer.') + return None + if lineno <= 0: + self.showerror('not a positive integer.') + return None + return lineno + + class HelpSource(Query): "Get menu name and help source for Help menu." # Used in ConfigDialog.HelpListItemAdd/Edit, (941/9) |