From 363fab83b8a0e6d924c7a7c577feec6a2812bb8c Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 9 Mar 2020 16:51:20 -0400 Subject: 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. --- Lib/idlelib/query.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Lib/idlelib/query.py') diff --git a/Lib/idlelib/query.py b/Lib/idlelib/query.py index 57616de4fe..2a88530b4d 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) -- cgit v1.2.1