bpo-27115: Move IDLE Query error blanking (GH-18868)

Move required blanking of error text to non-overridden entry_ok().
(Omit news item.)
(cherry picked from commit e53a3932cb)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2020-03-08 22:54:31 -07:00 committed by GitHub
parent f9684d222e
commit 9d5ed8355d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -108,6 +108,7 @@ class Query(Toplevel):
exists=True, root=self.parent) exists=True, root=self.parent)
self.entry_error = Label(frame, text=' ', foreground='red', self.entry_error = Label(frame, text=' ', foreground='red',
font=self.error_font) font=self.error_font)
# Display or blank error by setting ['text'] =.
entrylabel.grid(column=0, row=0, columnspan=3, padx=5, sticky=W) entrylabel.grid(column=0, row=0, columnspan=3, padx=5, sticky=W)
self.entry.grid(column=0, row=1, columnspan=3, padx=5, sticky=W+E, self.entry.grid(column=0, row=1, columnspan=3, padx=5, sticky=W+E,
pady=[10,0]) pady=[10,0])
@ -132,7 +133,6 @@ class Query(Toplevel):
def entry_ok(self): # Example: usually replace. def entry_ok(self): # Example: usually replace.
"Return non-blank entry or None." "Return non-blank entry or None."
self.entry_error['text'] = ''
entry = self.entry.get().strip() entry = self.entry.get().strip()
if not entry: if not entry:
self.showerror('blank line.') self.showerror('blank line.')
@ -144,6 +144,7 @@ class Query(Toplevel):
Otherwise leave dialog open for user to correct entry or cancel. Otherwise leave dialog open for user to correct entry or cancel.
''' '''
self.entry_error['text'] = ''
entry = self.entry_ok() entry = self.entry_ok()
if entry is not None: if entry is not None:
self.result = entry self.result = entry
@ -173,7 +174,6 @@ class SectionName(Query):
def entry_ok(self): def entry_ok(self):
"Return sensible ConfigParser section name or None." "Return sensible ConfigParser section name or None."
self.entry_error['text'] = ''
name = self.entry.get().strip() name = self.entry.get().strip()
if not name: if not name:
self.showerror('no name specified.') self.showerror('no name specified.')
@ -198,7 +198,6 @@ class ModuleName(Query):
def entry_ok(self): def entry_ok(self):
"Return entered module name as file path or None." "Return entered module name as file path or None."
self.entry_error['text'] = ''
name = self.entry.get().strip() name = self.entry.get().strip()
if not name: if not name:
self.showerror('no name specified.') self.showerror('no name specified.')
@ -311,7 +310,6 @@ class HelpSource(Query):
def entry_ok(self): def entry_ok(self):
"Return apparently valid (name, path) or None" "Return apparently valid (name, path) or None"
self.entry_error['text'] = ''
self.path_error['text'] = '' self.path_error['text'] = ''
name = self.item_ok() name = self.item_ok()
path = self.path_ok() path = self.path_ok()
@ -362,7 +360,6 @@ class CustomRun(Query):
def entry_ok(self): def entry_ok(self):
"Return apparently valid (cli_args, restart) or None" "Return apparently valid (cli_args, restart) or None"
self.entry_error['text'] = ''
cli_args = self.cli_args_ok() cli_args = self.cli_args_ok()
restart = self.restartvar.get() restart = self.restartvar.get()
return None if cli_args is None else (cli_args, restart) return None if cli_args is None else (cli_args, restart)