diff options
author | Georg Brandl <georg@python.org> | 2008-05-20 07:13:37 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-20 07:13:37 (GMT) |
commit | 6634bf2919d855ccd821e878b8cc00c7209f1cbe (patch) | |
tree | 77ef2dfaaf00ec144e75ac19708e4dd457604ebc /Lib/lib-tk | |
parent | 33cece05b918dff706a4298e33f84d8e8a0391d2 (diff) | |
download | cpython-6634bf2919d855ccd821e878b8cc00c7209f1cbe.zip cpython-6634bf2919d855ccd821e878b8cc00c7209f1cbe.tar.gz cpython-6634bf2919d855ccd821e878b8cc00c7209f1cbe.tar.bz2 |
Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Diffstat (limited to 'Lib/lib-tk')
-rw-r--r-- | Lib/lib-tk/Canvas.py | 2 | ||||
-rw-r--r-- | Lib/lib-tk/Dialog.py | 4 | ||||
-rw-r--r-- | Lib/lib-tk/ScrolledText.py | 4 | ||||
-rwxr-xr-x | Lib/lib-tk/Tix.py | 18 | ||||
-rw-r--r-- | Lib/lib-tk/Tkdnd.py | 12 | ||||
-rw-r--r-- | Lib/lib-tk/Tkinter.py | 19 | ||||
-rw-r--r-- | Lib/lib-tk/tkColorChooser.py | 2 | ||||
-rw-r--r-- | Lib/lib-tk/tkCommonDialog.py | 6 | ||||
-rw-r--r-- | Lib/lib-tk/tkFont.py | 20 | ||||
-rw-r--r-- | Lib/lib-tk/tkMessageBox.py | 2 | ||||
-rw-r--r-- | Lib/lib-tk/turtle.py | 10 |
11 files changed, 50 insertions, 49 deletions
diff --git a/Lib/lib-tk/Canvas.py b/Lib/lib-tk/Canvas.py index d35b1f5..34464ab 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/Dialog.py b/Lib/lib-tk/Dialog.py index 75e7fed..2d08959 100644 --- a/Lib/lib-tk/Dialog.py +++ b/Lib/lib-tk/Dialog.py @@ -1,7 +1,7 @@ # dialog.py -- Tkinter interface to the tk_dialog script. -from tkinter import * -from tkinter import _cnfmerge +from Tkinter import * +from Tkinter import _cnfmerge if TkVersion <= 3.6: DIALOG_ICON = 'warning' diff --git a/Lib/lib-tk/ScrolledText.py b/Lib/lib-tk/ScrolledText.py index c96bc3b..367aa89 100644 --- a/Lib/lib-tk/ScrolledText.py +++ b/Lib/lib-tk/ScrolledText.py @@ -10,8 +10,8 @@ # Most methods calls are inherited from the Text widget; Pack methods # are redirected to the Frame widget however. -from tkinter import * -from tkinter import _cnfmerge +from Tkinter import * +from Tkinter import _cnfmerge class ScrolledText(Text): def __init__(self, master=None, cnf=None, **kw): diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py index 22a9000..b7a0fc0 100755 --- a/Lib/lib-tk/Tix.py +++ b/Lib/lib-tk/Tix.py @@ -26,8 +26,8 @@ # appreciate the advantages. # -from tkinter import * -from tkinter import _flatten, _cnfmerge, _default_root +from Tkinter import * +from Tkinter import _flatten, _cnfmerge, _default_root # WARNING - TkVersion is a limited precision floating point number if TkVersion < 3.999: @@ -57,7 +57,7 @@ TCL_ALL_EVENTS = 0 # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore # liable to break. -import tkinter, os +import Tkinter, os # Could probably add this to Tkinter.Misc class tixCommand: @@ -192,11 +192,11 @@ class tixCommand: else: return self.tk.call('tix', 'resetoptions', newScheme, newFontSet) -class Tk(tkinter.Tk, tixCommand): +class Tk(Tkinter.Tk, tixCommand): """Toplevel widget of Tix which represents mostly the main window of an application. It has an associated Tcl interpreter.""" def __init__(self, screenName=None, baseName=None, className='Tix'): - tkinter.Tk.__init__(self, screenName, baseName, className) + Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') if tixlib is not None: @@ -212,7 +212,7 @@ class Tk(tkinter.Tk, tixCommand): def destroy(self): # For safety, remove an delete_window binding before destroy self.protocol("WM_DELETE_WINDOW", "") - tkinter.Tk.destroy(self) + Tkinter.Tk.destroy(self) # The Tix 'tixForm' geometry manager class Form: @@ -260,9 +260,9 @@ class Form: -tkinter.Widget.__bases__ = tkinter.Widget.__bases__ + (Form,) +Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,) -class TixWidget(tkinter.Widget): +class TixWidget(Tkinter.Widget): """A TixWidget class is used to package all (or most) Tix widgets. Widget initialization is extended in two ways: @@ -383,7 +383,7 @@ class TixWidget(tkinter.Widget): # These are missing from Tkinter def image_create(self, imgtype, cnf={}, master=None, **kw): if not master: - master = tkinter._default_root + master = Tkinter._default_root if not master: raise RuntimeError, 'Too early to create image' if kw and cnf: cnf = _cnfmerge((cnf, kw)) diff --git a/Lib/lib-tk/Tkdnd.py b/Lib/lib-tk/Tkdnd.py index 55f0776..2e37d9e 100644 --- a/Lib/lib-tk/Tkdnd.py +++ b/Lib/lib-tk/Tkdnd.py @@ -100,7 +100,7 @@ active; it will never call dnd_commit(). """ -import tkinter +import Tkinter # The factory function @@ -219,7 +219,7 @@ class Icon: self.detach() if not canvas: return - label = tkinter.Label(canvas, text=self.name, + label = Tkinter.Label(canvas, text=self.name, borderwidth=2, relief="raised") id = canvas.create_window(x, y, window=label, anchor="nw") self.canvas = canvas @@ -268,8 +268,8 @@ class Icon: class Tester: def __init__(self, root): - self.top = tkinter.Toplevel(root) - self.canvas = tkinter.Canvas(self.top, width=100, height=100) + self.top = Tkinter.Toplevel(root) + self.canvas = Tkinter.Canvas(self.top, width=100, height=100) self.canvas.pack(fill="both", expand=1) self.canvas.dnd_accept = self.dnd_accept @@ -300,9 +300,9 @@ class Tester: source.attach(self.canvas, x, y) def test(): - root = tkinter.Tk() + root = Tkinter.Tk() root.geometry("+1+1") - tkinter.Button(command=root.quit, text="Quit").pack() + Tkinter.Button(command=root.quit, text="Quit").pack() t1 = Tester(root) t1.top.geometry("+1+60") t2 = Tester(root) diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index d83b2ba..dccabad 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -18,14 +18,14 @@ Actions are bound to events by resources (e.g. keyword argument command) or with the method bind. Example (Hello, World): -import tkinter -from tkinter.constants import * -tk = tkinter.Tk() -frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) +import Tkinter +from Tkconstants import * +tk = Tkinter.Tk() +frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) -label = tkinter.Label(frame, text="Hello, World") +label = Tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) -button = tkinter.Button(frame,text="Exit",command=tk.destroy) +button = Tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() """ @@ -35,11 +35,12 @@ __version__ = "$Revision$" import sys if sys.platform == "win32": # Attempt to configure Tcl/Tk without requiring PATH - from tkinter import _fix + import FixTk import _tkinter # If this fails your Python may not be configured for Tk +tkinter = _tkinter # b/w compat for export TclError = _tkinter.TclError from types import * -from tkinter.constants import * +from Tkconstants import * try: import MacOS; _MacOS = MacOS; del MacOS except ImportError: @@ -1697,7 +1698,7 @@ class Tk(Misc, Wm): base_tcl = os.path.join(home, '.%s.tcl' % baseName) base_py = os.path.join(home, '.%s.py' % baseName) dir = {'self': self} - exec 'from tkinter import *' in dir + exec 'from Tkinter import *' in dir if os.path.isfile(class_tcl): self.tk.call('source', class_tcl) if os.path.isfile(class_py): diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/lib-tk/tkColorChooser.py index 77b391a..a55a797 100644 --- a/Lib/lib-tk/tkColorChooser.py +++ b/Lib/lib-tk/tkColorChooser.py @@ -19,7 +19,7 @@ # - title: dialog title # -from tkinter.commondialog import Dialog +from tkCommonDialog import Dialog # diff --git a/Lib/lib-tk/tkCommonDialog.py b/Lib/lib-tk/tkCommonDialog.py index f61eb45..2cd9be4 100644 --- a/Lib/lib-tk/tkCommonDialog.py +++ b/Lib/lib-tk/tkCommonDialog.py @@ -1,14 +1,14 @@ # base class for tk common dialogues # # this module provides a base class for accessing the common -# dialogues available in Tk 4.2 and newer. use filedialog, -# colorchooser, and messagebox to access the individual +# dialogues available in Tk 4.2 and newer. use tkFileDialog, +# tkColorChooser, and tkMessageBox to access the individual # dialogs. # # written by Fredrik Lundh, May 1997 # -from tkinter import * +from Tkinter import * class Dialog: diff --git a/Lib/lib-tk/tkFont.py b/Lib/lib-tk/tkFont.py index c23f047..229f251 100644 --- a/Lib/lib-tk/tkFont.py +++ b/Lib/lib-tk/tkFont.py @@ -8,7 +8,7 @@ __version__ = "0.9" -import tkinter +import Tkinter # weight/slant NORMAL = "normal" @@ -31,7 +31,7 @@ class Font: name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. - Raises _tkinter.TclError if the assertion is false. + Raises _Tkinter.TclError if the assertion is false. the following are ignored if font is specified: @@ -65,7 +65,7 @@ class Font: def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: - root = tkinter._default_root + root = Tkinter._default_root if font: # get actual settings corresponding to the given font font = root.tk.splitlist(root.tk.call("font", "actual", font)) @@ -79,7 +79,7 @@ class Font: self.delete_font = False # confirm font exists if self.name not in root.tk.call("font", "names"): - raise tkinter._tkinter.TclError, "named font %s does not already exist" % (self.name,) + raise Tkinter._tkinter.TclError, "named font %s does not already exist" % (self.name,) # if font config info supplied, apply it if font: root.tk.call("font", "configure", self.name, *font) @@ -166,13 +166,13 @@ class Font: def families(root=None): "Get font families (as a tuple)" if not root: - root = tkinter._default_root + root = Tkinter._default_root return root.tk.splitlist(root.tk.call("font", "families")) def names(root=None): "Get names of defined fonts (as a tuple)" if not root: - root = tkinter._default_root + root = Tkinter._default_root return root.tk.splitlist(root.tk.call("font", "names")) # -------------------------------------------------------------------- @@ -180,7 +180,7 @@ def names(root=None): if __name__ == "__main__": - root = tkinter.Tk() + root = Tkinter.Tk() # create a font f = Font(family="times", size=30, weight=NORMAL) @@ -202,10 +202,10 @@ if __name__ == "__main__": f = Font(font=("Courier", 20, "bold")) print f.measure("hello"), f.metrics("linespace") - w = tkinter.Label(root, text="Hello, world", font=f) + w = Tkinter.Label(root, text="Hello, world", font=f) w.pack() - w = tkinter.Button(root, text="Quit!", command=root.destroy) + w = Tkinter.Button(root, text="Quit!", command=root.destroy) w.pack() fb = Font(font=w["font"]).copy() @@ -213,4 +213,4 @@ if __name__ == "__main__": w.config(font=fb) - tkinter.mainloop() + Tkinter.mainloop() diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/lib-tk/tkMessageBox.py index df0a163..8f7483f 100644 --- a/Lib/lib-tk/tkMessageBox.py +++ b/Lib/lib-tk/tkMessageBox.py @@ -22,7 +22,7 @@ # - type: dialog type; that is, which buttons to display (see below) # -from tkinter.commondialog import Dialog +from Tkinter.commondialog import Dialog # # constants diff --git a/Lib/lib-tk/turtle.py b/Lib/lib-tk/turtle.py index 0d343e6..e4cac29 100644 --- a/Lib/lib-tk/turtle.py +++ b/Lib/lib-tk/turtle.py @@ -16,7 +16,7 @@ pictures can easily be drawn. from math import * # Also for export from time import sleep -import tkinter +import Tkinter speeds = ['fastest', 'fast', 'normal', 'slow', 'slowest'] @@ -238,7 +238,7 @@ class RawPen: # Test the color first try: id = self._canvas.create_line(0, 0, 0, 0, fill=color) - except tkinter.TclError: + except Tkinter.TclError: raise Error, "bad color string: %r" % (color,) self._set_color(color) return @@ -554,7 +554,7 @@ class RawPen: # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") - except tkinter.TclError: + except Tkinter.TclError: # Probably the window was closed! return else: @@ -638,13 +638,13 @@ class Pen(RawPen): def __init__(self): global _root, _canvas if _root is None: - _root = tkinter.Tk() + _root = Tkinter.Tk() _root.wm_protocol("WM_DELETE_WINDOW", self._destroy) _root.title(_title) if _canvas is None: # XXX Should have scroll bars - _canvas = tkinter.Canvas(_root, background="white") + _canvas = Tkinter.Canvas(_root, background="white") _canvas.pack(expand=1, fill="both") setup(width=_width, height= _height, startx=_startx, starty=_starty) |