From ad9afeb8f02db9a13d2ed8e45361ecbc0d19bd32 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 16 May 2008 15:48:15 +0000 Subject: [PATCH] Tkinter rename, step 2: fix imports and add stub modules. --- Lib/idlelib/AutoCompleteWindow.py | 2 +- Lib/idlelib/CallTipWindow.py | 2 +- Lib/idlelib/CodeContext.py | 6 ++--- Lib/idlelib/ColorDelegator.py | 2 +- Lib/idlelib/Debugger.py | 2 +- Lib/idlelib/EditorWindow.py | 8 +++---- Lib/idlelib/FileList.py | 4 ++-- Lib/idlelib/GrepDialog.py | 2 +- Lib/idlelib/IOBinding.py | 8 +++---- Lib/idlelib/MultiCall.py | 8 +++---- Lib/idlelib/MultiStatusBar.py | 2 +- Lib/idlelib/ObjectBrowser.py | 2 +- Lib/idlelib/OutputWindow.py | 4 ++-- Lib/idlelib/Percolator.py | 2 +- Lib/idlelib/PyShell.py | 10 ++++---- Lib/idlelib/ReplaceDialog.py | 2 +- Lib/idlelib/ScriptBinding.py | 2 +- Lib/idlelib/ScrolledList.py | 2 +- Lib/idlelib/SearchDialog.py | 2 +- Lib/idlelib/SearchDialogBase.py | 2 +- Lib/idlelib/SearchEngine.py | 4 ++-- Lib/idlelib/StackViewer.py | 4 ++-- Lib/idlelib/ToolTip.py | 2 +- Lib/idlelib/TreeWidget.py | 2 +- Lib/idlelib/UndoDelegator.py | 2 +- Lib/idlelib/WidgetRedirector.py | 2 +- Lib/idlelib/WindowList.py | 2 +- Lib/idlelib/aboutDialog.py | 2 +- Lib/idlelib/configDialog.py | 6 +++-- Lib/idlelib/configHelpSourceEdit.py | 6 ++--- Lib/idlelib/configSectionNameDialog.py | 4 ++-- Lib/idlelib/dynOptionMenuWidget.py | 4 ++-- Lib/idlelib/keybindingDialog.py | 4 ++-- Lib/idlelib/macosxSupport.py | 6 ++--- Lib/idlelib/run.py | 6 ++--- Lib/idlelib/tabbedpages.py | 2 +- Lib/idlelib/textView.py | 6 ++--- Lib/lib-tk/Canvas.py | 2 +- Lib/lib-tk/FileDialog.py | 8 +++++++ Lib/lib-tk/FixTk.py | 8 +++++++ Lib/lib-tk/ScrolledText.py | 8 +++++++ Lib/lib-tk/SimpleDialog.py | 8 +++++++ Lib/lib-tk/Tix.py | 8 +++++++ Lib/lib-tk/Tkconstants.py | 8 +++++++ Lib/lib-tk/Tkdnd.py | 8 +++++++ Lib/lib-tk/Tkinter.py | 8 +++++++ Lib/lib-tk/tkColorChooser.py | 8 +++++++ Lib/lib-tk/tkCommonDialog.py | 8 +++++++ Lib/lib-tk/tkFont.py | 8 +++++++ Lib/lib-tk/tkMessageBox.py | 8 +++++++ Lib/lib-tk/turtle.py | 8 +++++++ Lib/pydoc.py | 32 +++++++++++++------------- Lib/test/test_py3kwarn.py | 15 ++++++++++++ 53 files changed, 206 insertions(+), 85 deletions(-) create mode 100644 Lib/lib-tk/FileDialog.py create mode 100644 Lib/lib-tk/FixTk.py create mode 100644 Lib/lib-tk/ScrolledText.py create mode 100644 Lib/lib-tk/SimpleDialog.py create mode 100644 Lib/lib-tk/Tix.py create mode 100644 Lib/lib-tk/Tkconstants.py create mode 100644 Lib/lib-tk/Tkdnd.py create mode 100644 Lib/lib-tk/Tkinter.py create mode 100644 Lib/lib-tk/tkColorChooser.py create mode 100644 Lib/lib-tk/tkCommonDialog.py create mode 100644 Lib/lib-tk/tkFont.py create mode 100644 Lib/lib-tk/tkMessageBox.py create mode 100644 Lib/lib-tk/turtle.py diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/AutoCompleteWindow.py index 635775d954a..ab132c10e7e 100644 --- a/Lib/idlelib/AutoCompleteWindow.py +++ b/Lib/idlelib/AutoCompleteWindow.py @@ -1,7 +1,7 @@ """ An auto-completion window for IDLE, used by the AutoComplete extension """ -from Tkinter import * +from tkinter import * from MultiCall import MC_SHIFT import AutoComplete diff --git a/Lib/idlelib/CallTipWindow.py b/Lib/idlelib/CallTipWindow.py index 22238855c16..27ed0859c88 100644 --- a/Lib/idlelib/CallTipWindow.py +++ b/Lib/idlelib/CallTipWindow.py @@ -4,7 +4,7 @@ After ToolTip.py, which uses ideas gleaned from PySol Used by the CallTips IDLE extension. """ -from Tkinter import * +from tkinter import * HIDE_VIRTUAL_EVENT_NAME = "<>" HIDE_SEQUENCES = ("", "") diff --git a/Lib/idlelib/CodeContext.py b/Lib/idlelib/CodeContext.py index 420ec339ca2..941bb26d174 100644 --- a/Lib/idlelib/CodeContext.py +++ b/Lib/idlelib/CodeContext.py @@ -9,8 +9,8 @@ variable in the CodeContext section of config-extensions.def. Lines which do not open blocks are not shown in the context hints pane. """ -import Tkinter -from Tkconstants import TOP, LEFT, X, W, SUNKEN +import tkinter +from tkinter.constants import TOP, LEFT, X, W, SUNKEN from configHandler import idleConf import re from sys import maxint as INFINITY @@ -69,7 +69,7 @@ class CodeContext: border = 0 for widget in widgets: border += int(str( widget.cget('border') )) - self.label = Tkinter.Label(self.editwin.top, + self.label = tkinter.Label(self.editwin.top, text="\n" * (self.context_depth - 1), anchor=W, justify=LEFT, font=self.textfont, diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py index e55f9e6b77b..fb84805df61 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -2,7 +2,7 @@ import time import re import keyword import __builtin__ -from Tkinter import * +from tkinter import * from Delegator import Delegator from configHandler import idleConf diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py index a56c224e65a..fa2a56b610c 100644 --- a/Lib/idlelib/Debugger.py +++ b/Lib/idlelib/Debugger.py @@ -1,7 +1,7 @@ import os import bdb import types -from Tkinter import * +from tkinter import * from WindowList import ListedToplevel from ScrolledList import ScrolledList import macosxSupport diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 8d35198c179..2f728b332b3 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -3,9 +3,9 @@ import os import re import imp from itertools import count -from Tkinter import * -import tkSimpleDialog -import tkMessageBox +from tkinter import * +import tkinter.simpledialog as tkSimpleDialog +import tkinter.messagebox as tkMessageBox from MultiCall import MultiCallCreator import webbrowser @@ -45,7 +45,7 @@ class EditorWindow(object): from UndoDelegator import UndoDelegator from IOBinding import IOBinding, filesystemencoding, encoding import Bindings - from Tkinter import Toplevel + from tkinter import Toplevel from MultiStatusBar import MultiStatusBar help_url = None diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py index e40c7a7a849..45203347dda 100644 --- a/Lib/idlelib/FileList.py +++ b/Lib/idlelib/FileList.py @@ -1,6 +1,6 @@ import os -from Tkinter import * -import tkMessageBox +from tkinter import * +import tkinter.messagebox as tkMessageBox class FileList: diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py index ab136bc1128..ccee522df0d 100644 --- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/GrepDialog.py @@ -1,7 +1,7 @@ import os import fnmatch import sys -from Tkinter import * +from tkinter import * import SearchEngine from SearchDialogBase import SearchDialogBase diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py index 01d278e87cd..e18ff3f83a2 100644 --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -10,11 +10,11 @@ import types import sys import codecs import tempfile -import tkFileDialog -import tkMessageBox +import tkinter.filedialog as tkFileDialog +import tkinter.messagebox as tkMessageBox import re -from Tkinter import * -from SimpleDialog import SimpleDialog +from tkinter import * +from tkinter.simpledialog import SimpleDialog from configHandler import idleConf diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py index 51de6390aa8..269ab3f547d 100644 --- a/Lib/idlelib/MultiCall.py +++ b/Lib/idlelib/MultiCall.py @@ -32,7 +32,7 @@ Each function will be called at most once for each event. import sys import string import re -import Tkinter +import tkinter # the event type constants, which define the meaning of mc_type MC_KEYPRESS=0; MC_KEYRELEASE=1; MC_BUTTONPRESS=2; MC_BUTTONRELEASE=3; @@ -292,7 +292,7 @@ def MultiCallCreator(widget): return _multicall_dict[widget] class MultiCall (widget): - assert issubclass(widget, Tkinter.Misc) + assert issubclass(widget, tkinter.Misc) def __init__(self, *args, **kwargs): apply(widget.__init__, (self,)+args, kwargs) @@ -382,8 +382,8 @@ def MultiCallCreator(widget): if __name__ == "__main__": # Test - root = Tkinter.Tk() - text = MultiCallCreator(Tkinter.Text)(root) + root = tkinter.Tk() + text = MultiCallCreator(tkinter.Text)(root) text.pack() def bindseq(seq, n=[0]): def handler(event): diff --git a/Lib/idlelib/MultiStatusBar.py b/Lib/idlelib/MultiStatusBar.py index 2d4c5473d40..dadc42d2cd7 100644 --- a/Lib/idlelib/MultiStatusBar.py +++ b/Lib/idlelib/MultiStatusBar.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * class MultiStatusBar(Frame): diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/ObjectBrowser.py index 8ff0041766e..c328cdcb77d 100644 --- a/Lib/idlelib/ObjectBrowser.py +++ b/Lib/idlelib/ObjectBrowser.py @@ -136,7 +136,7 @@ def make_objecttreeitem(labeltext, object, setfunction=None): def _test(): import sys - from Tkinter import Tk + from tkinter import Tk root = Tk() root.configure(bd=0, bg="yellow") root.focus_set() diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py index 787e9b0bba0..afc4e3954e5 100644 --- a/Lib/idlelib/OutputWindow.py +++ b/Lib/idlelib/OutputWindow.py @@ -1,7 +1,7 @@ -from Tkinter import * +from tkinter import * from EditorWindow import EditorWindow import re -import tkMessageBox +import tkinter.messagebox as tkMessageBox import IOBinding class OutputWindow(EditorWindow): diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/Percolator.py index ebbcba9e6a6..21d8a47756b 100644 --- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/Percolator.py @@ -81,5 +81,5 @@ def main(): root.mainloop() if __name__ == "__main__": - from Tkinter import * + from tkinter import * main() diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index a17f81ff402..4754866e033 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -17,12 +17,12 @@ import linecache from code import InteractiveInterpreter try: - from Tkinter import * + from tkinter import * except ImportError: - print>>sys.__stderr__, "** IDLE can't import Tkinter. " \ + print>>sys.__stderr__, "** IDLE can't import tkinter. " \ "Your Python may not be configured for Tk. **" sys.exit(1) -import tkMessageBox +import tkinter.messagebox as tkMessageBox from EditorWindow import EditorWindow, fixwordbreaks from FileList import FileList @@ -992,8 +992,8 @@ class PyShell(OutputWindow): (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.IDLE_VERSION, nosub)) self.showprompt() - import Tkinter - Tkinter._default_root = None # 03Jan04 KBK What's this? + import tkinter + tkinter._default_root = None # 03Jan04 KBK What's this? return True def readline(self): diff --git a/Lib/idlelib/ReplaceDialog.py b/Lib/idlelib/ReplaceDialog.py index c8eb1c8c459..c8f67840b9a 100644 --- a/Lib/idlelib/ReplaceDialog.py +++ b/Lib/idlelib/ReplaceDialog.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * import SearchEngine from SearchDialogBase import SearchDialogBase diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index cb01110726a..c6892f3d4dc 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -22,7 +22,7 @@ import re import string import tabnanny import tokenize -import tkMessageBox +import tkinter.messagebox as tkMessageBox import PyShell from configHandler import idleConf diff --git a/Lib/idlelib/ScrolledList.py b/Lib/idlelib/ScrolledList.py index 92119365770..f92348863bb 100644 --- a/Lib/idlelib/ScrolledList.py +++ b/Lib/idlelib/ScrolledList.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * class ScrolledList: diff --git a/Lib/idlelib/SearchDialog.py b/Lib/idlelib/SearchDialog.py index d7124d67ff2..6c90d288da0 100644 --- a/Lib/idlelib/SearchDialog.py +++ b/Lib/idlelib/SearchDialog.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * import SearchEngine from SearchDialogBase import SearchDialogBase diff --git a/Lib/idlelib/SearchDialogBase.py b/Lib/idlelib/SearchDialogBase.py index f63e7ae37c7..65914ac24ec 100644 --- a/Lib/idlelib/SearchDialogBase.py +++ b/Lib/idlelib/SearchDialogBase.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * class SearchDialogBase: diff --git a/Lib/idlelib/SearchEngine.py b/Lib/idlelib/SearchEngine.py index cc40a00c50f..2d05af86a1b 100644 --- a/Lib/idlelib/SearchEngine.py +++ b/Lib/idlelib/SearchEngine.py @@ -1,6 +1,6 @@ import re -from Tkinter import * -import tkMessageBox +from tkinter import * +import tkinter.messagebox as tkMessageBox def get(root): if not hasattr(root, "_searchengine"): diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/StackViewer.py index 6b7730bcdbb..794726d62e7 100644 --- a/Lib/idlelib/StackViewer.py +++ b/Lib/idlelib/StackViewer.py @@ -7,7 +7,7 @@ from ObjectBrowser import ObjectTreeItem, make_objecttreeitem def StackBrowser(root, flist=None, tb=None, top=None): if top is None: - from Tkinter import Toplevel + from tkinter import Toplevel top = Toplevel(root) sc = ScrolledCanvas(top, bg="white", highlightthickness=0) sc.frame.pack(expand=1, fill="both") @@ -128,7 +128,7 @@ def _test(): reload(testcode) except: sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() - from Tkinter import Tk + from tkinter import Tk root = Tk() StackBrowser(None, top=root) root.mainloop() diff --git a/Lib/idlelib/ToolTip.py b/Lib/idlelib/ToolTip.py index ce7a3d3ee52..b178803b02f 100644 --- a/Lib/idlelib/ToolTip.py +++ b/Lib/idlelib/ToolTip.py @@ -3,7 +3,7 @@ # may be useful for some purposes in (or almost in ;) the current project scope # Ideas gleaned from PySol -from Tkinter import * +from tkinter import * class ToolTipBase: diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py index 5299e0e951d..876cb0df41d 100644 --- a/Lib/idlelib/TreeWidget.py +++ b/Lib/idlelib/TreeWidget.py @@ -15,7 +15,7 @@ # - optimize tree redraw after expand of subnode import os -from Tkinter import * +from tkinter import * import imp import ZoomHeight diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py index 5896bd5d1b6..544be10559e 100644 --- a/Lib/idlelib/UndoDelegator.py +++ b/Lib/idlelib/UndoDelegator.py @@ -1,5 +1,5 @@ import string -from Tkinter import * +from tkinter import * from Delegator import Delegator #$ event <> diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py index 7c341f2f1e4..a87e65069f4 100644 --- a/Lib/idlelib/WidgetRedirector.py +++ b/Lib/idlelib/WidgetRedirector.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * class WidgetRedirector: diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/WindowList.py index 658502b20b0..ccf35a8b01e 100644 --- a/Lib/idlelib/WindowList.py +++ b/Lib/idlelib/WindowList.py @@ -1,4 +1,4 @@ -from Tkinter import * +from tkinter import * class WindowList: diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py index 008602cd269..4900c094f00 100644 --- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/aboutDialog.py @@ -2,7 +2,7 @@ """ -from Tkinter import * +from tkinter import * import os import os.path import textView diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index acab0534864..68cc3fef81c 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -9,8 +9,10 @@ Note that tab width in IDLE is currently fixed at eight due to Tk issues. Refer to comments in EditorWindow autoindent code for details. """ -from Tkinter import * -import tkMessageBox, tkColorChooser, tkFont +from tkinter import * +import tkinter.messagebox as tkMessageBox +import tkinter.colorchooser as tkColorChooser +import tkinter.font as tkFont import string from configHandler import idleConf diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py index 661162196c7..b80c54883bf 100644 --- a/Lib/idlelib/configHelpSourceEdit.py +++ b/Lib/idlelib/configHelpSourceEdit.py @@ -3,9 +3,9 @@ import os import sys -from Tkinter import * -import tkMessageBox -import tkFileDialog +from tkinter import * +import tkinter.messagebox as tkMessageBox +import tkinter.filedialog as tkFileDialog class GetHelpSourceDialog(Toplevel): def __init__(self, parent, title, menuItem='', filePath=''): diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/configSectionNameDialog.py index 4f1b002afca..bcf132c7ef6 100644 --- a/Lib/idlelib/configSectionNameDialog.py +++ b/Lib/idlelib/configSectionNameDialog.py @@ -2,8 +2,8 @@ Dialog that allows user to specify a new config file section name. Used to get new highlight theme and keybinding set names. """ -from Tkinter import * -import tkMessageBox +from tkinter import * +import tkinter.messagebox as tkMessageBox class GetCfgSectionNameDialog(Toplevel): def __init__(self,parent,title,message,usedNames): diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynOptionMenuWidget.py index e81f7babe05..90fc3231a3b 100644 --- a/Lib/idlelib/dynOptionMenuWidget.py +++ b/Lib/idlelib/dynOptionMenuWidget.py @@ -2,8 +2,8 @@ OptionMenu widget modified to allow dynamic menu reconfiguration and setting of highlightthickness """ -from Tkinter import OptionMenu -from Tkinter import _setit +from tkinter import OptionMenu +from tkinter import _setit import copy class DynOptionMenu(OptionMenu): diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py index 1ce7ff46860..e58ac73042b 100644 --- a/Lib/idlelib/keybindingDialog.py +++ b/Lib/idlelib/keybindingDialog.py @@ -1,8 +1,8 @@ """ Dialog for building Tkinter accelerator key bindings """ -from Tkinter import * -import tkMessageBox +from tkinter import * +import tkinter.messagebox as tkMessageBox import string class GetKeysDialog(Toplevel): diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py index 222abfce753..c76381dc89c 100644 --- a/Lib/idlelib/macosxSupport.py +++ b/Lib/idlelib/macosxSupport.py @@ -3,7 +3,7 @@ A number of function that enhance IDLE on MacOSX when it used as a normal GUI application (as opposed to an X11 application). """ import sys -import Tkinter +import tkinter def runningAsOSXApp(): """ Returns True iff running from the IDLE.app bundle on OSX """ @@ -26,7 +26,7 @@ def addOpenEventSupport(root, flist): def hideTkConsole(root): try: root.tk.call('console', 'hide') - except Tkinter.TclError: + except tkinter.TclError: # Some versions of the Tk framework don't have a console object pass @@ -46,7 +46,7 @@ def overrideRootMenu(root, flist): # # Due to a (mis-)feature of TkAqua the user will also see an empty Help # menu. - from Tkinter import Menu, Text, Text + from tkinter import Menu, Text, Text from EditorWindow import prepstr, get_accelerator import Bindings import WindowList diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 8abbe5010ec..18ddca75443 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -127,9 +127,9 @@ def manage_socket(address): server.handle_request() # A single request only def show_socket_error(err, address): - import Tkinter - import tkMessageBox - root = Tkinter.Tk() + import tkinter + import tkinter.messagebox as tkMessageBox + root = tkinter.Tk() root.withdraw() if err[0] == 61: # connection refused msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\ diff --git a/Lib/idlelib/tabbedpages.py b/Lib/idlelib/tabbedpages.py index 8d7113dfa93..429af5d55d8 100644 --- a/Lib/idlelib/tabbedpages.py +++ b/Lib/idlelib/tabbedpages.py @@ -7,7 +7,7 @@ TabbedPageSet -- A Tkinter implementation of a tabbed-page widget. TabSet -- A widget containing tabs (buttons) in one or more rows. """ -from Tkinter import * +from tkinter import * class InvalidNameError(Exception): pass class AlreadyExistsError(Exception): pass diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index 0e7e6631856..3f3c2477891 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -2,8 +2,8 @@ """ -from Tkinter import * -import tkMessageBox +from tkinter import * +import tkinter.messagebox as tkMessageBox class TextViewer(Toplevel): """A simple text viewer dialog for IDLE @@ -68,7 +68,7 @@ def view_file(parent, title, filename, encoding=None): else: textFile = open(filename, 'r') except IOError: - import tkMessageBox + import tkinter.messagebox as tkMessageBox tkMessageBox.showerror(title='File Load Error', message='Unable to load file %r .' % filename, parent=parent) diff --git a/Lib/lib-tk/Canvas.py b/Lib/lib-tk/Canvas.py index 34464ab979f..d35b1f5d223 100644 --- a/Lib/lib-tk/Canvas.py +++ b/Lib/lib-tk/Canvas.py @@ -7,7 +7,7 @@ from warnings import warnpy3k warnpy3k("the Canvas module has been removed in Python 3.0", stacklevel=2) del warnpy3k -from Tkinter import Canvas, _cnfmerge, _flatten +from tkinter import Canvas, _cnfmerge, _flatten class CanvasItem: diff --git a/Lib/lib-tk/FileDialog.py b/Lib/lib-tk/FileDialog.py new file mode 100644 index 00000000000..390f8360597 --- /dev/null +++ b/Lib/lib-tk/FileDialog.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the FileDialog module has been renamed " + "to 'tkinter.filedialog' in Python 3.0", stacklevel=2) + +import tkinter.filedialog +sys.modules[__name__] = tkinter.filedialog diff --git a/Lib/lib-tk/FixTk.py b/Lib/lib-tk/FixTk.py new file mode 100644 index 00000000000..d19605aa3bd --- /dev/null +++ b/Lib/lib-tk/FixTk.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the FixTk module has been renamed " + "to 'tkinter._fix' in Python 3.0", stacklevel=2) + +import tkinter._fix +sys.modules[__name__] = tkinter._fix diff --git a/Lib/lib-tk/ScrolledText.py b/Lib/lib-tk/ScrolledText.py new file mode 100644 index 00000000000..1566d8933aa --- /dev/null +++ b/Lib/lib-tk/ScrolledText.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the ScrolledText module has been renamed " + "to 'tkinter.scrolledtext' in Python 3.0", stacklevel=2) + +import tkinter.scrolledtext +sys.modules[__name__] = tkinter.scrolledtext diff --git a/Lib/lib-tk/SimpleDialog.py b/Lib/lib-tk/SimpleDialog.py new file mode 100644 index 00000000000..707f2f54b73 --- /dev/null +++ b/Lib/lib-tk/SimpleDialog.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the SimpleDialog module has been renamed " + "to 'tkinter.simpledialog' in Python 3.0", stacklevel=2) + +import tkinter.simpledialog +sys.modules[__name__] = tkinter.simpledialog diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py new file mode 100644 index 00000000000..77d3df09e13 --- /dev/null +++ b/Lib/lib-tk/Tix.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the Tix module has been renamed " + "to 'tkinter.tix' in Python 3.0", stacklevel=2) + +import tkinter.tix +sys.modules[__name__] = tkinter.tix diff --git a/Lib/lib-tk/Tkconstants.py b/Lib/lib-tk/Tkconstants.py new file mode 100644 index 00000000000..1cf2c8f8bd7 --- /dev/null +++ b/Lib/lib-tk/Tkconstants.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the Tkconstants module has been renamed " + "to 'tkinter.constants' in Python 3.0", stacklevel=2) + +import tkinter.constants +sys.modules[__name__] = tkinter.constants diff --git a/Lib/lib-tk/Tkdnd.py b/Lib/lib-tk/Tkdnd.py new file mode 100644 index 00000000000..dfc0f74a3a0 --- /dev/null +++ b/Lib/lib-tk/Tkdnd.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the Tkdnd module has been renamed " + "to 'tkinter.dnd' in Python 3.0", stacklevel=2) + +import tkinter.dnd +sys.modules[__name__] = tkinter.dnd diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py new file mode 100644 index 00000000000..4e56a37452e --- /dev/null +++ b/Lib/lib-tk/Tkinter.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the Tkinter module has been renamed " + "to 'tkinter' in Python 3.0", stacklevel=2) + +import tkinter +sys.modules[__name__] = tkinter diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/lib-tk/tkColorChooser.py new file mode 100644 index 00000000000..284bc27ae3f --- /dev/null +++ b/Lib/lib-tk/tkColorChooser.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the tkColorChooser module has been renamed " + "to 'tkinter.colorchooser' in Python 3.0", stacklevel=2) + +import tkinter.colorchooser +sys.modules[__name__] = tkinter.colorchooser diff --git a/Lib/lib-tk/tkCommonDialog.py b/Lib/lib-tk/tkCommonDialog.py new file mode 100644 index 00000000000..80fcd453178 --- /dev/null +++ b/Lib/lib-tk/tkCommonDialog.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the tkCommonDialog module has been renamed " + "to 'tkinter.commondialog' in Python 3.0", stacklevel=2) + +import tkinter.commondialog +sys.modules[__name__] = tkinter.commondialog diff --git a/Lib/lib-tk/tkFont.py b/Lib/lib-tk/tkFont.py new file mode 100644 index 00000000000..0e12bc09791 --- /dev/null +++ b/Lib/lib-tk/tkFont.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the tkFont module has been renamed " + "to 'tkinter.font' in Python 3.0", stacklevel=2) + +import tkinter.font +sys.modules[__name__] = tkinter.font diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/lib-tk/tkMessageBox.py new file mode 100644 index 00000000000..cea676de884 --- /dev/null +++ b/Lib/lib-tk/tkMessageBox.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the tkMessageBox module has been renamed " + "to 'tkinter.messagebox' in Python 3.0", stacklevel=2) + +import tkinter.messagebox +sys.modules[__name__] = tkinter.messagebox diff --git a/Lib/lib-tk/turtle.py b/Lib/lib-tk/turtle.py new file mode 100644 index 00000000000..88b8c613bdc --- /dev/null +++ b/Lib/lib-tk/turtle.py @@ -0,0 +1,8 @@ +import sys +from warnings import warnpy3k + +warnpy3k("the turtle module has been renamed " + "to 'tkinter.turtle' in Python 3.0", stacklevel=2) + +import tkinter.turtle +sys.modules[__name__] = tkinter.turtle diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 987d2137d7f..bdfc9429324 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2017,20 +2017,20 @@ def gui(): self.server = None self.scanner = None - import Tkinter - self.server_frm = Tkinter.Frame(window) - self.title_lbl = Tkinter.Label(self.server_frm, + import tkinter + self.server_frm = tkinter.Frame(window) + self.title_lbl = tkinter.Label(self.server_frm, text='Starting server...\n ') - self.open_btn = Tkinter.Button(self.server_frm, + self.open_btn = tkinter.Button(self.server_frm, text='open browser', command=self.open, state='disabled') - self.quit_btn = Tkinter.Button(self.server_frm, + self.quit_btn = tkinter.Button(self.server_frm, text='quit serving', command=self.quit, state='disabled') - self.search_frm = Tkinter.Frame(window) - self.search_lbl = Tkinter.Label(self.search_frm, text='Search for') - self.search_ent = Tkinter.Entry(self.search_frm) + self.search_frm = tkinter.Frame(window) + self.search_lbl = tkinter.Label(self.search_frm, text='Search for') + self.search_ent = tkinter.Entry(self.search_frm) self.search_ent.bind('', self.search) - self.stop_btn = Tkinter.Button(self.search_frm, + self.stop_btn = tkinter.Button(self.search_frm, text='stop', pady=0, command=self.stop, state='disabled') if sys.platform == 'win32': # Trying to hide and show this button crashes under Windows. @@ -2049,17 +2049,17 @@ def gui(): self.search_ent.focus_set() font = ('helvetica', sys.platform == 'win32' and 8 or 10) - self.result_lst = Tkinter.Listbox(window, font=font, height=6) + self.result_lst = tkinter.Listbox(window, font=font, height=6) self.result_lst.bind('', self.select) self.result_lst.bind('', self.goto) - self.result_scr = Tkinter.Scrollbar(window, + self.result_scr = tkinter.Scrollbar(window, orient='vertical', command=self.result_lst.yview) self.result_lst.config(yscrollcommand=self.result_scr.set) - self.result_frm = Tkinter.Frame(window) - self.goto_btn = Tkinter.Button(self.result_frm, + self.result_frm = tkinter.Frame(window) + self.goto_btn = tkinter.Button(self.result_frm, text='go to selected', command=self.goto) - self.hide_btn = Tkinter.Button(self.result_frm, + self.hide_btn = tkinter.Button(self.result_frm, text='hide results', command=self.hide) self.goto_btn.pack(side='left', fill='x', expand=1) self.hide_btn.pack(side='right', fill='x', expand=1) @@ -2179,9 +2179,9 @@ def gui(): self.stop() self.collapse() - import Tkinter + import tkinter try: - root = Tkinter.Tk() + root = tkinter.Tk() # Tk will crash if pythonw.exe has an XP .manifest # file and the root has is not destroyed explicitly. # If the problem is ever fixed in Tk, the explicit diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index 857810a45c1..c6160dac97c 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -212,6 +212,21 @@ class TestStdlibRenames(unittest.TestCase): 'SocketServer': 'socketserver', 'ConfigParser': 'configparser', 'repr': 'reprlib', + 'FileDialog': 'tkinter.filedialog', + 'FixTk': 'tkinter._fix', + 'ScrolledText': 'tkinter.scrolledtext', + 'SimpleDialog': 'tkinter.simpledialog', + 'Tix': 'tkinter.tix', + 'tkColorChooser': 'tkinter.colorchooser', + 'tkCommonDialog': 'tkinter.commondialog', + 'Tkconstants': 'tkinter.constants', + 'Tkdnd': 'tkinter.dnd', + 'tkFileDialog': 'tkinter.filedialog', + 'tkFont': 'tkinter.font', + 'Tkinter': 'tkinter', + 'tkMessageBox': 'tkinter.messagebox', + 'tkSimpleDialog': 'tkinter.simpledialog', + 'turtle': 'tkinter.turtle' } def check_rename(self, module_name, new_module_name):