bpo-43013: Fix old tkinter module names in idlelib (GH-24326)

Lowercase 'tkColorChooser', 'tkFileDialog', 'tkSimpleDialog', and
'tkMessageBox' and remove 'tk'.  Just lowercase 'tkFont' as 'font'
is already used.  Adjust import.
(cherry picked from commit 879986d8a9)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2021-01-25 05:25:39 -08:00 committed by GitHub
parent 3d5434d5cb
commit 26af2fae18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 66 additions and 67 deletions

View file

@ -18,8 +18,8 @@ from tkinter import (Toplevel, Listbox, Scale, Canvas,
HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END) HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END)
from tkinter.ttk import (Frame, LabelFrame, Button, Checkbutton, Entry, Label, from tkinter.ttk import (Frame, LabelFrame, Button, Checkbutton, Entry, Label,
OptionMenu, Notebook, Radiobutton, Scrollbar, Style) OptionMenu, Notebook, Radiobutton, Scrollbar, Style)
import tkinter.colorchooser as tkColorChooser from tkinter import colorchooser
import tkinter.font as tkFont import tkinter.font as tkfont
from tkinter import messagebox from tkinter import messagebox
from idlelib.config import idleConf, ConfigChanges from idlelib.config import idleConf, ConfigChanges
@ -609,7 +609,7 @@ class FontPage(Frame):
font_bold = configured_font[2]=='bold' font_bold = configured_font[2]=='bold'
# Set sorted no-duplicate editor font selection list and font_name. # Set sorted no-duplicate editor font selection list and font_name.
fonts = sorted(set(tkFont.families(self))) fonts = sorted(set(tkfont.families(self)))
for font in fonts: for font in fonts:
self.fontlist.insert(END, font) self.fontlist.insert(END, font)
self.font_name.set(font_name) self.font_name.set(font_name)
@ -663,7 +663,7 @@ class FontPage(Frame):
Updates font_sample and highlight page highlight_sample. Updates font_sample and highlight page highlight_sample.
""" """
font_name = self.font_name.get() font_name = self.font_name.get()
font_weight = tkFont.BOLD if self.font_bold.get() else tkFont.NORMAL font_weight = tkfont.BOLD if self.font_bold.get() else tkfont.NORMAL
new_font = (font_name, self.font_size.get(), font_weight) new_font = (font_name, self.font_size.get(), font_weight)
self.font_sample['font'] = new_font self.font_sample['font'] = new_font
self.highlight_sample['font'] = new_font self.highlight_sample['font'] = new_font
@ -1100,7 +1100,7 @@ class HighPage(Frame):
target = self.highlight_target.get() target = self.highlight_target.get()
prev_color = self.style.lookup(self.frame_color_set['style'], prev_color = self.style.lookup(self.frame_color_set['style'],
'background') 'background')
rgbTuplet, color_string = tkColorChooser.askcolor( rgbTuplet, color_string = colorchooser.askcolor(
parent=self, title='Pick new color for : '+target, parent=self, title='Pick new color for : '+target,
initialcolor=prev_color) initialcolor=prev_color)
if color_string and (color_string != prev_color): if color_string and (color_string != prev_color):

View file

@ -12,8 +12,8 @@ import webbrowser
from tkinter import * from tkinter import *
from tkinter.font import Font from tkinter.font import Font
from tkinter.ttk import Scrollbar from tkinter.ttk import Scrollbar
import tkinter.simpledialog as tkSimpleDialog from tkinter import simpledialog
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
from idlelib.config import idleConf from idlelib.config import idleConf
from idlelib import configdialog from idlelib import configdialog
@ -295,9 +295,9 @@ class EditorWindow:
window.register_callback(self.postwindowsmenu) window.register_callback(self.postwindowsmenu)
# Some abstractions so IDLE extensions are cross-IDE # Some abstractions so IDLE extensions are cross-IDE
self.askyesno = tkMessageBox.askyesno self.askinteger = simpledialog.askinteger
self.askinteger = tkSimpleDialog.askinteger self.askyesno = messagebox.askyesno
self.showerror = tkMessageBox.showerror self.showerror = messagebox.showerror
# Add pseudoevents for former extension fixed keys. # Add pseudoevents for former extension fixed keys.
# (This probably needs to be done once in the process.) # (This probably needs to be done once in the process.)
@ -596,7 +596,7 @@ class EditorWindow:
try: try:
os.startfile(self.help_url) os.startfile(self.help_url)
except OSError as why: except OSError as why:
tkMessageBox.showerror(title='Document Start Failure', messagebox.showerror(title='Document Start Failure',
message=str(why), parent=self.text) message=str(why), parent=self.text)
else: else:
webbrowser.open(self.help_url) webbrowser.open(self.help_url)
@ -927,7 +927,7 @@ class EditorWindow:
try: try:
os.startfile(helpfile) os.startfile(helpfile)
except OSError as why: except OSError as why:
tkMessageBox.showerror(title='Document Start Failure', messagebox.showerror(title='Document Start Failure',
message=str(why), parent=self.text) message=str(why), parent=self.text)
else: else:
webbrowser.open(helpfile) webbrowser.open(helpfile)
@ -963,7 +963,7 @@ class EditorWindow:
except OSError as err: except OSError as err:
if not getattr(self.root, "recentfiles_message", False): if not getattr(self.root, "recentfiles_message", False):
self.root.recentfiles_message = True self.root.recentfiles_message = True
tkMessageBox.showwarning(title='IDLE Warning', messagebox.showwarning(title='IDLE Warning',
message="Cannot save Recent Files list to disk.\n" message="Cannot save Recent Files list to disk.\n"
f" {err}\n" f" {err}\n"
"Select OK to continue.", "Select OK to continue.",

View file

@ -1,7 +1,7 @@
"idlelib.filelist" "idlelib.filelist"
import os import os
from tkinter import messagebox as tkMessageBox from tkinter import messagebox
class FileList: class FileList:
@ -20,7 +20,7 @@ class FileList:
filename = self.canonize(filename) filename = self.canonize(filename)
if os.path.isdir(filename): if os.path.isdir(filename):
# This can happen when bad filename is passed on command line: # This can happen when bad filename is passed on command line:
tkMessageBox.showerror( messagebox.showerror(
"File Error", "File Error",
"%r is a directory." % (filename,), "%r is a directory." % (filename,),
master=self.root) master=self.root)
@ -88,7 +88,7 @@ class FileList:
if newkey in self.dict: if newkey in self.dict:
conflict = self.dict[newkey] conflict = self.dict[newkey]
self.inversedict[conflict] = None self.inversedict[conflict] = None
tkMessageBox.showerror( messagebox.showerror(
"Name Conflict", "Name Conflict",
"You now have multiple edit windows open for %r" % (filename,), "You now have multiple edit windows open for %r" % (filename,),
master=self.root) master=self.root)

View file

@ -59,27 +59,26 @@ class Mbox_func:
class Mbox: class Mbox:
"""Mock for tkinter.messagebox with an Mbox_func for each function. """Mock for tkinter.messagebox with an Mbox_func for each function.
This module was 'tkMessageBox' in 2.x; hence the 'import as' in 3.x.
Example usage in test_module.py for testing functions in module.py: Example usage in test_module.py for testing functions in module.py:
--- ---
from idlelib.idle_test.mock_tk import Mbox from idlelib.idle_test.mock_tk import Mbox
import module import module
orig_mbox = module.tkMessageBox orig_mbox = module.messagebox
showerror = Mbox.showerror # example, for attribute access in test methods showerror = Mbox.showerror # example, for attribute access in test methods
class Test(unittest.TestCase): class Test(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
module.tkMessageBox = Mbox module.messagebox = Mbox
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
module.tkMessageBox = orig_mbox module.messagebox = orig_mbox
--- ---
For 'ask' functions, set func.result return value before calling the method For 'ask' functions, set func.result return value before calling the method
that uses the message function. When tkMessageBox functions are the that uses the message function. When messagebox functions are the
only gui alls in a method, this replacement makes the method gui-free, only gui alls in a method, this replacement makes the method gui-free,
""" """
askokcancel = Mbox_func() # True or False askokcancel = Mbox_func() # True or False

View file

@ -423,7 +423,7 @@ class HighPageTest(unittest.TestCase):
def test_color(self): def test_color(self):
d = self.page d = self.page
d.on_new_color_set = Func() d.on_new_color_set = Func()
# self.color is only set in get_color through ColorChooser. # self.color is only set in get_color through colorchooser.
d.color.set('green') d.color.set('green')
self.assertEqual(d.on_new_color_set.called, 1) self.assertEqual(d.on_new_color_set.called, 1)
del d.on_new_color_set del d.on_new_color_set
@ -540,8 +540,8 @@ class HighPageTest(unittest.TestCase):
def test_get_color(self): def test_get_color(self):
eq = self.assertEqual eq = self.assertEqual
d = self.page d = self.page
orig_chooser = configdialog.tkColorChooser.askcolor orig_chooser = configdialog.colorchooser.askcolor
chooser = configdialog.tkColorChooser.askcolor = Func() chooser = configdialog.colorchooser.askcolor = Func()
gntn = d.get_new_theme_name = Func() gntn = d.get_new_theme_name = Func()
d.highlight_target.set('Editor Breakpoint') d.highlight_target.set('Editor Breakpoint')
@ -582,7 +582,7 @@ class HighPageTest(unittest.TestCase):
eq(d.color.get(), '#de0000') eq(d.color.get(), '#de0000')
del d.get_new_theme_name del d.get_new_theme_name
configdialog.tkColorChooser.askcolor = orig_chooser configdialog.colorchooser.askcolor = orig_chooser
def test_on_new_color_set(self): def test_on_new_color_set(self):
d = self.page d = self.page

View file

@ -10,7 +10,7 @@ from unittest.mock import Mock
from idlelib.idle_test.mock_tk import Mbox from idlelib.idle_test.mock_tk import Mbox
import idlelib.searchengine as se import idlelib.searchengine as se
orig_mbox = se.tkMessageBox orig_mbox = se.messagebox
showerror = Mbox.showerror showerror = Mbox.showerror
@ -20,7 +20,7 @@ class ReplaceDialogTest(unittest.TestCase):
def setUpClass(cls): def setUpClass(cls):
cls.root = Tk() cls.root = Tk()
cls.root.withdraw() cls.root.withdraw()
se.tkMessageBox = Mbox se.messagebox = Mbox
cls.engine = se.SearchEngine(cls.root) cls.engine = se.SearchEngine(cls.root)
cls.dialog = ReplaceDialog(cls.root, cls.engine) cls.dialog = ReplaceDialog(cls.root, cls.engine)
cls.dialog.bell = lambda: None cls.dialog.bell = lambda: None
@ -32,7 +32,7 @@ class ReplaceDialogTest(unittest.TestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
se.tkMessageBox = orig_mbox se.messagebox = orig_mbox
del cls.text, cls.dialog, cls.engine del cls.text, cls.dialog, cls.engine
cls.root.destroy() cls.root.destroy()
del cls.root del cls.root

View file

@ -4,7 +4,7 @@ from idlelib import searchengine as se
import unittest import unittest
# from test.support import requires # from test.support import requires
from tkinter import BooleanVar, StringVar, TclError # ,Tk, Text from tkinter import BooleanVar, StringVar, TclError # ,Tk, Text
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
from idlelib.idle_test.mock_tk import Var, Mbox from idlelib.idle_test.mock_tk import Var, Mbox
from idlelib.idle_test.mock_tk import Text as mockText from idlelib.idle_test.mock_tk import Text as mockText
import re import re
@ -19,13 +19,13 @@ def setUpModule():
# Replace s-e module tkinter imports other than non-gui TclError. # Replace s-e module tkinter imports other than non-gui TclError.
se.BooleanVar = Var se.BooleanVar = Var
se.StringVar = Var se.StringVar = Var
se.tkMessageBox = Mbox se.messagebox = Mbox
def tearDownModule(): def tearDownModule():
# Restore 'just in case', though other tests should also replace. # Restore 'just in case', though other tests should also replace.
se.BooleanVar = BooleanVar se.BooleanVar = BooleanVar
se.StringVar = StringVar se.StringVar = StringVar
se.tkMessageBox = tkMessageBox se.messagebox = messagebox
class Mock: class Mock:

View file

@ -396,7 +396,7 @@ class ExpandingButtonTest(unittest.TestCase):
expandingbutton.base_text = expandingbutton.text expandingbutton.base_text = expandingbutton.text
# Patch the message box module to always return False. # Patch the message box module to always return False.
with patch('idlelib.squeezer.tkMessageBox') as mock_msgbox: with patch('idlelib.squeezer.messagebox') as mock_msgbox:
mock_msgbox.askokcancel.return_value = False mock_msgbox.askokcancel.return_value = False
mock_msgbox.askyesno.return_value = False mock_msgbox.askyesno.return_value = False
# Trigger the expand event. # Trigger the expand event.
@ -407,7 +407,7 @@ class ExpandingButtonTest(unittest.TestCase):
self.assertEqual(expandingbutton.text.get('1.0', 'end-1c'), '') self.assertEqual(expandingbutton.text.get('1.0', 'end-1c'), '')
# Patch the message box module to always return True. # Patch the message box module to always return True.
with patch('idlelib.squeezer.tkMessageBox') as mock_msgbox: with patch('idlelib.squeezer.messagebox') as mock_msgbox:
mock_msgbox.askokcancel.return_value = True mock_msgbox.askokcancel.return_value = True
mock_msgbox.askyesno.return_value = True mock_msgbox.askyesno.return_value = True
# Trigger the expand event. # Trigger the expand event.

View file

@ -5,8 +5,8 @@ import sys
import tempfile import tempfile
import tokenize import tokenize
import tkinter.filedialog as tkFileDialog from tkinter import filedialog
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
from tkinter.simpledialog import askstring from tkinter.simpledialog import askstring
import idlelib import idlelib
@ -147,10 +147,10 @@ class IOBinding:
eol_convention = f.newlines eol_convention = f.newlines
converted = True converted = True
except OSError as err: except OSError as err:
tkMessageBox.showerror("I/O Error", str(err), parent=self.text) messagebox.showerror("I/O Error", str(err), parent=self.text)
return False return False
except UnicodeDecodeError: except UnicodeDecodeError:
tkMessageBox.showerror("Decoding Error", messagebox.showerror("Decoding Error",
"File %s\nFailed to Decode" % filename, "File %s\nFailed to Decode" % filename,
parent=self.text) parent=self.text)
return False return False
@ -159,7 +159,7 @@ class IOBinding:
# If the file does not contain line separators, it is None. # If the file does not contain line separators, it is None.
# If the file contains mixed line separators, it is a tuple. # If the file contains mixed line separators, it is a tuple.
if eol_convention is not None: if eol_convention is not None:
tkMessageBox.showwarning("Mixed Newlines", messagebox.showwarning("Mixed Newlines",
"Mixed newlines detected.\n" "Mixed newlines detected.\n"
"The file will be changed on save.", "The file will be changed on save.",
parent=self.text) parent=self.text)
@ -187,10 +187,10 @@ class IOBinding:
return "yes" return "yes"
message = "Do you want to save %s before closing?" % ( message = "Do you want to save %s before closing?" % (
self.filename or "this untitled document") self.filename or "this untitled document")
confirm = tkMessageBox.askyesnocancel( confirm = messagebox.askyesnocancel(
title="Save On Close", title="Save On Close",
message=message, message=message,
default=tkMessageBox.YES, default=messagebox.YES,
parent=self.text) parent=self.text)
if confirm: if confirm:
reply = "yes" reply = "yes"
@ -249,7 +249,7 @@ class IOBinding:
os.fsync(f.fileno()) os.fsync(f.fileno())
return True return True
except OSError as msg: except OSError as msg:
tkMessageBox.showerror("I/O Error", str(msg), messagebox.showerror("I/O Error", str(msg),
parent=self.text) parent=self.text)
return False return False
@ -286,7 +286,7 @@ class IOBinding:
failed = str(err) failed = str(err)
except UnicodeEncodeError: except UnicodeEncodeError:
failed = "Invalid encoding '%s'" % enc failed = "Invalid encoding '%s'" % enc
tkMessageBox.showerror( messagebox.showerror(
"I/O Error", "I/O Error",
"%s.\nSaving as UTF-8" % failed, "%s.\nSaving as UTF-8" % failed,
parent=self.text) parent=self.text)
@ -295,10 +295,10 @@ class IOBinding:
return chars.encode('utf-8-sig') return chars.encode('utf-8-sig')
def print_window(self, event): def print_window(self, event):
confirm = tkMessageBox.askokcancel( confirm = messagebox.askokcancel(
title="Print", title="Print",
message="Print to Default Printer", message="Print to Default Printer",
default=tkMessageBox.OK, default=messagebox.OK,
parent=self.text) parent=self.text)
if not confirm: if not confirm:
self.text.focus_set() self.text.focus_set()
@ -336,10 +336,10 @@ class IOBinding:
status + output status + output
if output: if output:
output = "Printing command: %s\n" % repr(command) + output output = "Printing command: %s\n" % repr(command) + output
tkMessageBox.showerror("Print status", output, parent=self.text) messagebox.showerror("Print status", output, parent=self.text)
else: #no printing for this platform else: #no printing for this platform
message = "Printing is not enabled for this platform: %s" % platform message = "Printing is not enabled for this platform: %s" % platform
tkMessageBox.showinfo("Print status", message, parent=self.text) messagebox.showinfo("Print status", message, parent=self.text)
if tempfilename: if tempfilename:
os.unlink(tempfilename) os.unlink(tempfilename)
return "break" return "break"
@ -358,7 +358,7 @@ class IOBinding:
def askopenfile(self): def askopenfile(self):
dir, base = self.defaultfilename("open") dir, base = self.defaultfilename("open")
if not self.opendialog: if not self.opendialog:
self.opendialog = tkFileDialog.Open(parent=self.text, self.opendialog = filedialog.Open(parent=self.text,
filetypes=self.filetypes) filetypes=self.filetypes)
filename = self.opendialog.show(initialdir=dir, initialfile=base) filename = self.opendialog.show(initialdir=dir, initialfile=base)
return filename return filename
@ -378,7 +378,7 @@ class IOBinding:
def asksavefile(self): def asksavefile(self):
dir, base = self.defaultfilename("save") dir, base = self.defaultfilename("save")
if not self.savedialog: if not self.savedialog:
self.savedialog = tkFileDialog.SaveAs( self.savedialog = filedialog.SaveAs(
parent=self.text, parent=self.text,
filetypes=self.filetypes, filetypes=self.filetypes,
defaultextension=self.defaultextension) defaultextension=self.defaultextension)

View file

@ -21,13 +21,13 @@ if sys.platform == 'win32':
except (ImportError, AttributeError, OSError): except (ImportError, AttributeError, OSError):
pass pass
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
if TkVersion < 8.5: if TkVersion < 8.5:
root = Tk() # otherwise create root in main root = Tk() # otherwise create root in main
root.withdraw() root.withdraw()
from idlelib.run import fix_scaling from idlelib.run import fix_scaling
fix_scaling(root) fix_scaling(root)
tkMessageBox.showerror("Idle Cannot Start", messagebox.showerror("Idle Cannot Start",
"Idle requires tcl/tk 8.5+, not %s." % TkVersion, "Idle requires tcl/tk 8.5+, not %s." % TkVersion,
parent=root) parent=root)
raise SystemExit(1) raise SystemExit(1)
@ -261,7 +261,7 @@ class PyShellEditorWindow(EditorWindow):
except OSError as err: except OSError as err:
if not getattr(self.root, "breakpoint_error_displayed", False): if not getattr(self.root, "breakpoint_error_displayed", False):
self.root.breakpoint_error_displayed = True self.root.breakpoint_error_displayed = True
tkMessageBox.showerror(title='IDLE Error', messagebox.showerror(title='IDLE Error',
message='Unable to update breakpoint list:\n%s' message='Unable to update breakpoint list:\n%s'
% str(err), % str(err),
parent=self.text) parent=self.text)
@ -771,7 +771,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
exec(code, self.locals) exec(code, self.locals)
except SystemExit: except SystemExit:
if not self.tkconsole.closing: if not self.tkconsole.closing:
if tkMessageBox.askyesno( if messagebox.askyesno(
"Exit?", "Exit?",
"Do you want to exit altogether?", "Do you want to exit altogether?",
default="yes", default="yes",
@ -805,7 +805,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
return self.tkconsole.stderr.write(s) return self.tkconsole.stderr.write(s)
def display_port_binding_error(self): def display_port_binding_error(self):
tkMessageBox.showerror( messagebox.showerror(
"Port Binding Error", "Port Binding Error",
"IDLE can't bind to a TCP/IP port, which is necessary to " "IDLE can't bind to a TCP/IP port, which is necessary to "
"communicate with its Python execution server. This might be " "communicate with its Python execution server. This might be "
@ -816,7 +816,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
parent=self.tkconsole.text) parent=self.tkconsole.text)
def display_no_subprocess_error(self): def display_no_subprocess_error(self):
tkMessageBox.showerror( messagebox.showerror(
"Subprocess Connection Error", "Subprocess Connection Error",
"IDLE's subprocess didn't make connection.\n" "IDLE's subprocess didn't make connection.\n"
"See the 'Startup failure' section of the IDLE doc, online at\n" "See the 'Startup failure' section of the IDLE doc, online at\n"
@ -824,7 +824,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
parent=self.tkconsole.text) parent=self.tkconsole.text)
def display_executing_dialog(self): def display_executing_dialog(self):
tkMessageBox.showerror( messagebox.showerror(
"Already executing", "Already executing",
"The Python Shell window is already executing a command; " "The Python Shell window is already executing a command; "
"please wait until it is finished.", "please wait until it is finished.",
@ -945,7 +945,7 @@ class PyShell(OutputWindow):
def toggle_debugger(self, event=None): def toggle_debugger(self, event=None):
if self.executing: if self.executing:
tkMessageBox.showerror("Don't debug now", messagebox.showerror("Don't debug now",
"You can only toggle the debugger when idle", "You can only toggle the debugger when idle",
parent=self.text) parent=self.text)
self.set_debugger_indicator() self.set_debugger_indicator()
@ -1003,7 +1003,7 @@ class PyShell(OutputWindow):
def close(self): def close(self):
"Extend EditorWindow.close()" "Extend EditorWindow.close()"
if self.executing: if self.executing:
response = tkMessageBox.askokcancel( response = messagebox.askokcancel(
"Kill?", "Kill?",
"Your program is still running!\n Do you want to kill it?", "Your program is still running!\n Do you want to kill it?",
default="ok", default="ok",
@ -1254,7 +1254,7 @@ class PyShell(OutputWindow):
try: try:
sys.last_traceback sys.last_traceback
except: except:
tkMessageBox.showerror("No stack trace", messagebox.showerror("No stack trace",
"There is no stack trace yet.\n" "There is no stack trace yet.\n"
"(sys.last_traceback is not defined)", "(sys.last_traceback is not defined)",
parent=self.text) parent=self.text)

View file

@ -14,7 +14,7 @@ import tabnanny
import time import time
import tokenize import tokenize
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
from idlelib.config import idleConf from idlelib.config import idleConf
from idlelib import macosx from idlelib import macosx
@ -195,15 +195,15 @@ class ScriptBinding:
def ask_save_dialog(self): def ask_save_dialog(self):
msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?" msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
confirm = tkMessageBox.askokcancel(title="Save Before Run or Check", confirm = messagebox.askokcancel(title="Save Before Run or Check",
message=msg, message=msg,
default=tkMessageBox.OK, default=messagebox.OK,
parent=self.editwin.text) parent=self.editwin.text)
return confirm return confirm
def errorbox(self, title, message): def errorbox(self, title, message):
# XXX This should really be a function of EditorWindow... # XXX This should really be a function of EditorWindow...
tkMessageBox.showerror(title, message, parent=self.editwin.text) messagebox.showerror(title, message, parent=self.editwin.text)
self.editwin.text.focus_set() self.editwin.text.focus_set()
self.perf = time.perf_counter() self.perf = time.perf_counter()

View file

@ -2,7 +2,7 @@
import re import re
from tkinter import StringVar, BooleanVar, TclError from tkinter import StringVar, BooleanVar, TclError
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
def get(root): def get(root):
'''Return the singleton SearchEngine instance for the process. '''Return the singleton SearchEngine instance for the process.
@ -96,7 +96,7 @@ class SearchEngine:
msg = msg + "\nPattern: " + str(pat) msg = msg + "\nPattern: " + str(pat)
if col is not None: if col is not None:
msg = msg + "\nOffset: " + str(col) msg = msg + "\nOffset: " + str(col)
tkMessageBox.showerror("Regular expression error", messagebox.showerror("Regular expression error",
msg, master=self.root) msg, master=self.root)
def search_text(self, text, prog=None, ok=0): def search_text(self, text, prog=None, ok=0):

View file

@ -17,7 +17,7 @@ messages and their tracebacks.
import re import re
import tkinter as tk import tkinter as tk
import tkinter.messagebox as tkMessageBox from tkinter import messagebox
from idlelib.config import idleConf from idlelib.config import idleConf
from idlelib.textview import view_text from idlelib.textview import view_text
@ -147,7 +147,7 @@ class ExpandingButton(tk.Button):
if self.is_dangerous is None: if self.is_dangerous is None:
self.set_is_dangerous() self.set_is_dangerous()
if self.is_dangerous: if self.is_dangerous:
confirm = tkMessageBox.askokcancel( confirm = messagebox.askokcancel(
title="Expand huge output?", title="Expand huge output?",
message="\n\n".join([ message="\n\n".join([
"The squeezed output is very long: %d lines, %d chars.", "The squeezed output is very long: %d lines, %d chars.",
@ -155,7 +155,7 @@ class ExpandingButton(tk.Button):
"It is recommended to view or copy the output instead.", "It is recommended to view or copy the output instead.",
"Really expand?" "Really expand?"
]) % (self.numoflines, len(self.s)), ]) % (self.numoflines, len(self.s)),
default=tkMessageBox.CANCEL, default=messagebox.CANCEL,
parent=self.text) parent=self.text)
if not confirm: if not confirm:
return "break" return "break"