Commit ad9afeb8 authored by Georg Brandl's avatar Georg Brandl

Tkinter rename, step 2: fix imports and add stub modules.

parent bbc57d73
"""
An auto-completion window for IDLE, used by the AutoComplete extension
"""
from Tkinter import *
from tkinter import *
from MultiCall import MC_SHIFT
import AutoComplete
......
......@@ -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 = "<<calltipwindow-hide>>"
HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
......
......@@ -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,
......
......@@ -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
......
import os
import bdb
import types
from Tkinter import *
from tkinter import *
from WindowList import ListedToplevel
from ScrolledList import ScrolledList
import macosxSupport
......
......@@ -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
......
import os
from Tkinter import *
import tkMessageBox
from tkinter import *
import tkinter.messagebox as tkMessageBox
class FileList:
......
import os
import fnmatch
import sys
from Tkinter import *
from tkinter import *
import SearchEngine
from SearchDialogBase import SearchDialogBase
......
......@@ -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
......
......@@ -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):
......
from Tkinter import *
from tkinter import *
class MultiStatusBar(Frame):
......
......@@ -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()
......
from Tkinter import *
from tkinter import *
from EditorWindow import EditorWindow
import re
import tkMessageBox
import tkinter.messagebox as tkMessageBox
import IOBinding
class OutputWindow(EditorWindow):
......
......@@ -81,5 +81,5 @@ def main():
root.mainloop()
if __name__ == "__main__":
from Tkinter import *
from tkinter import *
main()
......@@ -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):
......
from Tkinter import *
from tkinter import *
import SearchEngine
from SearchDialogBase import SearchDialogBase
......
......@@ -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
......
from Tkinter import *
from tkinter import *
class ScrolledList:
......
from Tkinter import *
from tkinter import *
import SearchEngine
from SearchDialogBase import SearchDialogBase
......
from Tkinter import *
from tkinter import *
class SearchDialogBase:
......
import re
from Tkinter import *
import tkMessageBox
from tkinter import *
import tkinter.messagebox as tkMessageBox
def get(root):
if not hasattr(root, "_searchengine"):
......
......@@ -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()
......
......@@ -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:
......
......@@ -15,7 +15,7 @@
# - optimize tree redraw after expand of subnode
import os
from Tkinter import *
from tkinter import *
import imp
import ZoomHeight
......
import string
from Tkinter import *
from tkinter import *
from Delegator import Delegator
#$ event <<redo>>
......
from Tkinter import *
from tkinter import *
class WidgetRedirector:
......
from Tkinter import *
from tkinter import *
class WindowList:
......
......@@ -2,7 +2,7 @@
"""
from Tkinter import *
from tkinter import *
import os
import os.path
import textView
......
......@@ -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
......
......@@ -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=''):
......
......@@ -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):
......
......@@ -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):
......
"""
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):
......
......@@ -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
......
......@@ -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 "\
......
......@@ -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
......
......@@ -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)
......
......@@ -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:
......
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
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
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
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
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
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
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
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
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
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
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
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
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
......@@ -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('<Return>', 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('<Button-1>', self.select)
self.result_lst.bind('<Double-Button-1>', 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
......
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment