]> granicus.if.org Git - python/commitdiff
Make the Pynche tool work with Python 3.
authorGeorg Brandl <georg@python.org>
Mon, 2 Aug 2010 22:08:58 +0000 (22:08 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 2 Aug 2010 22:08:58 +0000 (22:08 +0000)
Tools/pynche/ChipViewer.py
Tools/pynche/DetailsViewer.py
Tools/pynche/ListViewer.py
Tools/pynche/PyncheWidget.py
Tools/pynche/StripViewer.py
Tools/pynche/Switchboard.py
Tools/pynche/TextViewer.py
Tools/pynche/TypeinViewer.py

index f59aa2819fa8da1418b5b7556f111bfe6b81bd9d..78139f8f2da9502b29f4381f49332eab9cc45506 100644 (file)
@@ -13,7 +13,7 @@ The ChipViewer class includes the entire lower left quandrant; i.e. both the
 selected and nearest ChipWidgets.
 """
 
-from Tkinter import *
+from tkinter import *
 import ColorDB
 
 \f
index 11a99a6afcab4ec01660d6484cfbc3836356a01c..fdc79b749ca9d0106358db89517841dc8441238b 100644 (file)
@@ -52,7 +52,7 @@ Shift + Left == -25
 Shift + Right == +25
 """
 
-from Tkinter import *
+from tkinter import *
 
 STOP = 'Stop'
 WRAP = 'Wrap Around'
index 213cd08ba7630660a4441d09258b64a8778feb0f..b18784453c3e02b683cdc3a9fdebbe741cb1914e 100644 (file)
@@ -15,7 +15,7 @@ You can turn off Update On Click if all you want to see is the alias for a
 given name, without selecting the color.
 """
 
-from Tkinter import *
+from tkinter import *
 import ColorDB
 
 ADDTOVIEW = 'Color %List Window...'
index fcfe7ce6c1f3bbbd0984b055031dd90c29b5ae73..364f22b0b2095c078c7a4fd8c2ca30a647c9cb6c 100644 (file)
@@ -6,9 +6,8 @@ It is used to bring up other windows.
 
 import sys
 import os
-from Tkinter import *
-import tkMessageBox
-import tkFileDialog
+from tkinter import *
+from tkinter import messagebox, filedialog
 import ColorDB
 
 # Milliseconds between interrupt checks
@@ -150,7 +149,7 @@ class PyncheWidget:
 
     def __popup_about(self, event=None):
         from Main import __version__
-        tkMessageBox.showinfo('About Pynche ' + __version__,
+        messagebox.showinfo('About Pynche ' + __version__,
                               '''\
 Pynche %s
 The PYthonically Natural
@@ -168,7 +167,7 @@ email:   bwarsaw@python.org''' % __version__)
     def __load(self, event=None):
         while 1:
             idir, ifile = os.path.split(self.__sb.colordb().filename())
-            file = tkFileDialog.askopenfilename(
+            file = filedialog.askopenfilename(
                 filetypes=[('Text files', '*.txt'),
                            ('All files', '*'),
                            ],
@@ -180,12 +179,12 @@ email:   bwarsaw@python.org''' % __version__)
             try:
                 colordb = ColorDB.get_colordb(file)
             except IOError:
-                tkMessageBox.showerror('Read error', '''\
+                messagebox.showerror('Read error', '''\
 Could not open file for reading:
 %s''' % file)
                 continue
             if colordb is None:
-                tkMessageBox.showerror('Unrecognized color file type', '''\
+                messagebox.showerror('Unrecognized color file type', '''\
 Unrecognized color file type in file:
 %s''' % file)
                 continue
@@ -249,6 +248,8 @@ class Helpwin:
 
 
 \f
+import functools
+@functools.total_ordering
 class PopupViewer:
     def __init__(self, module, name, switchboard, root):
         self.__m = module
@@ -279,8 +280,11 @@ class PopupViewer:
             self.__sb.add_view(self.__window)
         self.__window.deiconify()
 
-    def __cmp__(self, other):
-        return cmp(self.__menutext, other.__menutext)
+    def __eq__(self, other):
+        return self.__menutext == other.__menutext
+
+    def __lt__(self, other):
+        return self.__menutext < other.__menutext
 
 
 def make_view_popups(switchboard, root, extrapath):
index a7de398393bd575369d6f12105ab8072f39494c9..2b0ede39eeeff55cbb2b21f40ca75c9254a6c45d 100644 (file)
@@ -24,7 +24,7 @@ select the color under the cursor while you drag it, but be forewarned that
 this can be slow.
 """
 
-from Tkinter import *
+from tkinter import *
 import ColorDB
 
 # Load this script into the Tcl interpreter and call it in
@@ -62,32 +62,32 @@ def constant(numchips):
 # red variations, green+blue = cyan constant
 def constant_red_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, [red] * numchips, seq, seq))
+    return list(zip([red] * numchips, seq, seq))
 
 # green variations, red+blue = magenta constant
 def constant_green_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, seq, [green] * numchips, seq))
+    return list(zip(seq, [green] * numchips, seq))
 
 # blue variations, red+green = yellow constant
 def constant_blue_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, seq, seq, [blue] * numchips))
+    return list(zip(seq, seq, [blue] * numchips))
 
 # red variations, green+blue = cyan constant
 def constant_cyan_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, seq, [green] * numchips, [blue] * numchips))
+    return list(zip(seq, [green] * numchips, [blue] * numchips))
 
 # green variations, red+blue = magenta constant
 def constant_magenta_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, [red] * numchips, seq, [blue] * numchips))
+    return list(zip([red] * numchips, seq, [blue] * numchips))
 
 # blue variations, red+green = yellow constant
 def constant_yellow_generator(numchips, red, green, blue):
     seq = constant(numchips)
-    return list(map(None, [red] * numchips, [green] * numchips, seq))
+    return list(zip([red] * numchips, [green] * numchips, seq))
 
 
 \f
@@ -119,7 +119,7 @@ class LeftArrow:
         return arrow, text
 
     def _x(self):
-        coords = self._canvas.coords(self._TAG)
+        coords = list(self._canvas.coords(self._TAG))
         assert coords
         return coords[0]
 
@@ -151,7 +151,7 @@ class RightArrow(LeftArrow):
         return arrow, text
 
     def _x(self):
-        coords = self._canvas.coords(self._TAG)
+        coords = list(self._canvas.coords(self._TAG))
         assert coords
         return coords[0] + self._ARROWWIDTH
 
index 29f99afdd8ee5720bee6f5bf00fba647f8434710..013bb0138913916832f5a7085304f12230d9781c 100644 (file)
@@ -42,7 +42,6 @@ master window.
 """
 
 import sys
-from types import DictType
 import marshal
 
 
@@ -62,10 +61,11 @@ class Switchboard:
         if initfile:
             try:
                 try:
-                    fp = open(initfile)
+                    fp = open(initfile, 'rb')
                     self.__optiondb = marshal.load(fp)
-                    if not isinstance(self.__optiondb, DictType):
-                        print('Problem reading options from file:', initfile, file=sys.stderr)
+                    if not isinstance(self.__optiondb, dict):
+                        print('Problem reading options from file:', initfile,
+                              file=sys.stderr)
                         self.__optiondb = {}
                 except (IOError, EOFError, ValueError):
                     pass
@@ -116,7 +116,7 @@ class Switchboard:
         fp = None
         try:
             try:
-                fp = open(self.__initfile, 'w')
+                fp = open(self.__initfile, 'wb')
             except IOError:
                 print('Cannot write options to file:', \
                       self.__initfile, file=sys.stderr)
index 456bd96e3ff123b39cb15b1fb9853b58e9b60bb8..baa1e62ca760309f3891a4aa5b4eb95fdf0100b3 100644 (file)
@@ -15,7 +15,7 @@ button and drag it through some text.  The Insertion is the insertion cursor
 in the text window (which only has a background).
 """
 
-from Tkinter import *
+from tkinter import *
 import ColorDB
 
 ADDTOVIEW = 'Text Window...'
index d56c1b32c09f7bf61f887d14634714f1ccead0fc..2f93e6b44f4acb53dc94e802edfa9cb0532b720a 100644 (file)
@@ -12,7 +12,7 @@ color selection will be made on every change to the text field.  Otherwise,
 you must hit Return or Tab to select the color.
 """
 
-from Tkinter import *
+from tkinter import *
 
 
 \f