]> granicus.if.org Git - python/commitdiff
Step 1 of Tkinter renaming: move lib-tk modules into a new "tkinter" package.
authorGeorg Brandl <georg@python.org>
Fri, 16 May 2008 14:24:45 +0000 (14:24 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 16 May 2008 14:24:45 +0000 (14:24 +0000)
14 files changed:
Lib/tkinter/__init__.py [moved from Lib/lib-tk/Tkinter.py with 99% similarity]
Lib/tkinter/_fix.py [moved from Lib/lib-tk/FixTk.py with 100% similarity]
Lib/tkinter/colorchooser.py [moved from Lib/lib-tk/tkColorChooser.py with 97% similarity]
Lib/tkinter/commondialog.py [moved from Lib/lib-tk/tkCommonDialog.py with 89% similarity]
Lib/tkinter/constants.py [moved from Lib/lib-tk/Tkconstants.py with 100% similarity]
Lib/tkinter/dialog.py [moved from Lib/lib-tk/Dialog.py with 92% similarity]
Lib/tkinter/dnd.py [moved from Lib/lib-tk/Tkdnd.py with 97% similarity]
Lib/tkinter/filedialog.py [moved from Lib/lib-tk/FileDialog.py with 99% similarity]
Lib/tkinter/font.py [moved from Lib/lib-tk/tkFont.py with 94% similarity]
Lib/tkinter/messagebox.py [moved from Lib/lib-tk/tkMessageBox.py with 98% similarity]
Lib/tkinter/scrolledtext.py [moved from Lib/lib-tk/ScrolledText.py with 96% similarity]
Lib/tkinter/simpledialog.py [moved from Lib/lib-tk/SimpleDialog.py with 99% similarity]
Lib/tkinter/tix.py [moved from Lib/lib-tk/Tix.py with 99% similarity]
Lib/tkinter/turtle.py [moved from Lib/lib-tk/turtle.py with 99% similarity]

similarity index 99%
rename from Lib/lib-tk/Tkinter.py
rename to Lib/tkinter/__init__.py
index e8b47a4f1e771242d80c68a38824f39bc481766d..00af7370b44aa8f1a3f1323e5b672a71b73309d2 100644 (file)
@@ -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 Tkconstants import *
-tk = Tkinter.Tk()
-frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
+import tkinter
+from tkinter.constants 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()
 """
@@ -34,12 +34,13 @@ __version__ = "$Revision$"
 
 import sys
 if sys.platform == "win32":
-    import FixTk # Attempt to configure Tcl/Tk without requiring PATH
+    # Attempt to configure Tcl/Tk without requiring PATH
+    from tkinter import _fix
 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 Tkconstants import *
+from tkinter.constants import *
 try:
     import MacOS; _MacOS = MacOS; del MacOS
 except ImportError:
@@ -1696,7 +1697,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):
similarity index 100%
rename from Lib/lib-tk/FixTk.py
rename to Lib/tkinter/_fix.py
similarity index 97%
rename from Lib/lib-tk/tkColorChooser.py
rename to Lib/tkinter/colorchooser.py
index a55a797dd498e9cd108470f41b22813e60c28c37..77b391a1ccc4f5b042ecf183addf25f1e773a1e7 100644 (file)
@@ -19,7 +19,7 @@
 # - title: dialog title
 #
 
-from tkCommonDialog import Dialog
+from tkinter.commondialog import Dialog
 
 
 #
similarity index 89%
rename from Lib/lib-tk/tkCommonDialog.py
rename to Lib/tkinter/commondialog.py
index 2cd9be4eac0c8b20dae9ddb24933c62e538adcbd..f61eb45d1ec26e0a5b636c647ab51c17588aeadc 100644 (file)
@@ -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 tkFileDialog,
-# tkColorChooser, and tkMessageBox to access the individual
+# dialogues available in Tk 4.2 and newer.  use filedialog,
+# colorchooser, and messagebox to access the individual
 # dialogs.
 #
 # written by Fredrik Lundh, May 1997
 #
 
-from Tkinter import *
+from tkinter import *
 
 class Dialog:
 
similarity index 92%
rename from Lib/lib-tk/Dialog.py
rename to Lib/tkinter/dialog.py
index b52e5b49d292c2f12f1bed3feedf52ee2df1b4a0..75e7fede29f61b63297aab3efadde6cd0a7a817a 100644 (file)
@@ -1,7 +1,7 @@
-# Dialog.py -- Tkinter interface to the tk_dialog script.
+# 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'
similarity index 97%
rename from Lib/lib-tk/Tkdnd.py
rename to Lib/tkinter/dnd.py
index 2e37d9ec3952e1037bea384e6594a5b25bccad6a..55f0776ce9ad6fba3879f427e23c11f72db3fffd 100644 (file)
@@ -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)
similarity index 99%
rename from Lib/lib-tk/FileDialog.py
rename to Lib/tkinter/filedialog.py
index b08d3a84f85d0296aa60595888b5578be58f1021..727b3d74e4564402ae2d20003f38d8ba092b1078 100644 (file)
@@ -8,8 +8,8 @@ Classes:
 
 """
 
-from Tkinter import *
-from Dialog import Dialog
+from tkinter import *
+from tkinter.dialog import Dialog
 
 import os
 import fnmatch
similarity index 94%
rename from Lib/lib-tk/tkFont.py
rename to Lib/tkinter/font.py
index 15dea2eba3a561e7e3c4bdbc93995f4d28dfe233..c23f0471173d5d35e8e4c2a3a576bc4649121b69 100644 (file)
@@ -8,7 +8,7 @@
 
 __version__ = "0.9"
 
-import Tkinter
+import tkinter
 
 # weight/slant
 NORMAL = "normal"
@@ -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()
similarity index 98%
rename from Lib/lib-tk/tkMessageBox.py
rename to Lib/tkinter/messagebox.py
index d14ca86febc0bf592d5d3a9a18fc96b7efa50a5a..df0a163913e143f506c9bbd4654d6d464bc56e27 100644 (file)
@@ -22,7 +22,7 @@
 # - type: dialog type; that is, which buttons to display (see below)
 #
 
-from tkCommonDialog import Dialog
+from tkinter.commondialog import Dialog
 
 #
 # constants
similarity index 96%
rename from Lib/lib-tk/ScrolledText.py
rename to Lib/tkinter/scrolledtext.py
index 367aa89ca6798b2f08552111d8a33fa0aafd9658..c96bc3b5026d698e8544faa2de259d385ab92367 100644 (file)
@@ -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):
similarity index 99%
rename from Lib/lib-tk/SimpleDialog.py
rename to Lib/tkinter/simpledialog.py
index cb08318dbdd727f79e6729295600befa99913f7b..c89160de5be1f8d03b0d3c4ff69ff799d8246719 100644 (file)
@@ -1,7 +1,7 @@
 """A simple but flexible modal dialog box."""
 
 
-from Tkinter import *
+from tkinter import *
 
 
 class SimpleDialog:
similarity index 99%
rename from Lib/lib-tk/Tix.py
rename to Lib/tkinter/tix.py
index b7a0fc0776e0d5f56c2c49d59315689ce60e4a95..22a900018717521e0a774adacea7709a2554ed98 100755 (executable)
@@ -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))
similarity index 99%
rename from Lib/lib-tk/turtle.py
rename to Lib/tkinter/turtle.py
index e4cac294dfefe84306b7b6900787f4d4cdc88d01..0d343e628e53e458be0e981fa051c5b4b2561d4c 100644 (file)
@@ -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)