[Python-checkins] r45691 - python/branches/IDLE-syntax-branch/Lib/idlelib/CallTipWindow.py python/branches/IDLE-syntax-branch/Lib/idlelib/EditorWindow.py python/branches/IDLE-syntax-branch/Lib/idlelib/IOBinding.py python/branches/IDLE-syntax-branch/Lib/idlelib/NEWS.txt python/branches/IDLE-syntax-branch/Lib/idlelib/ToolTip.py python/branches/IDLE-syntax-branch/Lib/idlelib/config-extensions.def python/branches/IDLE-syntax-branch/Lib/idlelib/idlever.py python/branches/IDLE-syntax-branch/Lib/idlelib/keybindingDialog.py

kurt.kaiser python-checkins at python.org
Mon Apr 24 18:55:08 CEST 2006


Author: kurt.kaiser
Date: Mon Apr 24 18:55:07 2006
New Revision: 45691

Modified:
   python/branches/IDLE-syntax-branch/Lib/idlelib/CallTipWindow.py
   python/branches/IDLE-syntax-branch/Lib/idlelib/EditorWindow.py
   python/branches/IDLE-syntax-branch/Lib/idlelib/IOBinding.py
   python/branches/IDLE-syntax-branch/Lib/idlelib/NEWS.txt
   python/branches/IDLE-syntax-branch/Lib/idlelib/ToolTip.py
   python/branches/IDLE-syntax-branch/Lib/idlelib/config-extensions.def
   python/branches/IDLE-syntax-branch/Lib/idlelib/idlever.py
   python/branches/IDLE-syntax-branch/Lib/idlelib/keybindingDialog.py
Log:
Merge back changes to trunk since this branch was merged to trunk.
svn merge -r 41480:45690 svn+ssh://pythondev@svn.python.org/python/trunk/Lib/idlelib

M    ToolTip.py
M    keybindingDialog.py
M    EditorWindow.py
M    IOBinding.py
M    CallTipWindow.py
M    idlever.py
M    NEWS.txt
M    config-extensions.def


Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/CallTipWindow.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/CallTipWindow.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/CallTipWindow.py	Mon Apr 24 18:55:07 2006
@@ -6,7 +6,7 @@
 """
 from Tkinter import *
 
-HIDE_VIRTUAL_EVENT_NAME = "<<caltipwindow-hide>>"
+HIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-hide>>"
 HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
 CHECKHIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-checkhide>>"
 CHECKHIDE_SEQUENCES = ("<KeyRelease>", "<ButtonRelease>")
@@ -60,10 +60,7 @@
 
         self.tipwindow = tw = Toplevel(self.widget)
         self.position_window()
-        # XXX 12 Dec 2002 KBK The following command has two effects: It removes
-        #     the calltip window border (good) but also causes (at least on
-        #     Linux) the calltip to show as a top level window, burning through
-        #     any other window dragged over it.  Also, shows on all viewports!
+        # remove border on calltip window
         tw.wm_overrideredirect(1)
         try:
             # This command is only needed and available on Tk >= 8.4.0 for OSX

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/EditorWindow.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/EditorWindow.py	Mon Apr 24 18:55:07 2006
@@ -42,7 +42,7 @@
     from Percolator import Percolator
     from ColorDelegator import ColorDelegator
     from UndoDelegator import UndoDelegator
-    from IOBinding import IOBinding
+    from IOBinding import IOBinding, filesystemencoding, encoding
     import Bindings
     from Tkinter import Toplevel
     from MultiStatusBar import MultiStatusBar
@@ -256,6 +256,21 @@
         self.askinteger = tkSimpleDialog.askinteger
         self.showerror = tkMessageBox.showerror
 
+    def _filename_to_unicode(self, filename):
+        """convert filename to unicode in order to display it in Tk"""
+        if isinstance(filename, unicode) or not filename:
+            return filename
+        else:
+            try:
+                return filename.decode(self.filesystemencoding)
+            except UnicodeDecodeError:
+                # XXX
+                try:
+                    return filename.decode(self.encoding)
+                except UnicodeDecodeError:
+                    # byte-to-byte conversion
+                    return filename.decode('iso8859-1')
+
     def new_callback(self, event):
         dirname, basename = self.io.defaultfilename()
         self.flist.new(dirname)
@@ -566,47 +581,46 @@
     def RemoveKeybindings(self):
         "Remove the keybindings before they are changed."
         # Called from configDialog.py
-        self.Bindings.default_keydefs=idleConf.GetCurrentKeySet()
-        keydefs = self.Bindings.default_keydefs
+        self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
         for event, keylist in keydefs.items():
             self.text.event_delete(event, *keylist)
         for extensionName in self.get_standard_extension_names():
-            keydefs = idleConf.GetExtensionBindings(extensionName)
-            if keydefs:
-                for event, keylist in keydefs.items():
+            xkeydefs = idleConf.GetExtensionBindings(extensionName)
+            if xkeydefs:
+                for event, keylist in xkeydefs.items():
                     self.text.event_delete(event, *keylist)
 
     def ApplyKeybindings(self):
         "Update the keybindings after they are changed"
         # Called from configDialog.py
-        self.Bindings.default_keydefs=idleConf.GetCurrentKeySet()
+        self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
         self.apply_bindings()
         for extensionName in self.get_standard_extension_names():
-            keydefs = idleConf.GetExtensionBindings(extensionName)
-            if keydefs:
-                self.apply_bindings(keydefs)
+            xkeydefs = idleConf.GetExtensionBindings(extensionName)
+            if xkeydefs:
+                self.apply_bindings(xkeydefs)
         #update menu accelerators
-        menuEventDict={}
+        menuEventDict = {}
         for menu in self.Bindings.menudefs:
-            menuEventDict[menu[0]]={}
+            menuEventDict[menu[0]] = {}
             for item in menu[1]:
                 if item:
-                    menuEventDict[menu[0]][prepstr(item[0])[1]]=item[1]
+                    menuEventDict[menu[0]][prepstr(item[0])[1]] = item[1]
         for menubarItem in self.menudict.keys():
-            menu=self.menudict[menubarItem]
-            end=menu.index(END)+1
-            for index in range(0,end):
-                if menu.type(index)=='command':
-                    accel=menu.entrycget(index,'accelerator')
+            menu = self.menudict[menubarItem]
+            end = menu.index(END) + 1
+            for index in range(0, end):
+                if menu.type(index) == 'command':
+                    accel = menu.entrycget(index, 'accelerator')
                     if accel:
-                        itemName=menu.entrycget(index,'label')
-                        event=''
+                        itemName = menu.entrycget(index, 'label')
+                        event = ''
                         if menuEventDict.has_key(menubarItem):
                             if menuEventDict[menubarItem].has_key(itemName):
-                                event=menuEventDict[menubarItem][itemName]
+                                event = menuEventDict[menubarItem][itemName]
                         if event:
-                            accel=get_accelerator(keydefs, event)
-                            menu.entryconfig(index,accelerator=accel)
+                            accel = get_accelerator(keydefs, event)
+                            menu.entryconfig(index, accelerator=accel)
 
     def set_notabs_indentwidth(self):
         "Update the indentwidth if changed and not using tabs in this window"
@@ -676,8 +690,10 @@
             menu.delete(1, END)  # clear, and rebuild:
             for i, file in zip(count(), rf_list):
                 file_name = file[0:-1]  # zap \n
+                # make unicode string to display non-ASCII chars correctly
+                ufile_name = self._filename_to_unicode(file_name)
                 callback = instance.__recent_file_callback(file_name)
-                menu.add_command(label=ulchars[i] + " " + file_name,
+                menu.add_command(label=ulchars[i] + " " + ufile_name,
                                  command=callback,
                                  underline=0)
 
@@ -717,10 +733,12 @@
         filename = self.io.filename
         if filename:
             filename = os.path.basename(filename)
-        return filename
+        # return unicode string to display non-ASCII chars correctly
+        return self._filename_to_unicode(filename)
 
     def long_title(self):
-        return self.io.filename or ""
+        # return unicode string to display non-ASCII chars correctly
+        return self._filename_to_unicode(self.io.filename or "")
 
     def center_insert_event(self, event):
         self.center()

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/IOBinding.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/IOBinding.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/IOBinding.py	Mon Apr 24 18:55:07 2006
@@ -32,6 +32,9 @@
 except (ImportError, locale.Error):
     pass
 
+# Encoding for file names
+filesystemencoding = sys.getfilesystemencoding()
+
 encoding = "ascii"
 if sys.platform == 'win32':
     # On Windows, we could use "mbcs". However, to give the user
@@ -374,6 +377,7 @@
         try:
             f = open(filename, "wb")
             f.write(chars)
+            f.flush()
             f.close()
             return True
         except IOError, msg:
@@ -517,7 +521,10 @@
         if not self.opendialog:
             self.opendialog = tkFileDialog.Open(master=self.text,
                                                 filetypes=self.filetypes)
-        return self.opendialog.show(initialdir=dir, initialfile=base)
+        filename = self.opendialog.show(initialdir=dir, initialfile=base)
+        if isinstance(filename, unicode):
+            filename = filename.encode(filesystemencoding)
+        return filename
 
     def defaultfilename(self, mode="open"):
         if self.filename:
@@ -536,7 +543,10 @@
         if not self.savedialog:
             self.savedialog = tkFileDialog.SaveAs(master=self.text,
                                                   filetypes=self.filetypes)
-        return self.savedialog.show(initialdir=dir, initialfile=base)
+        filename = self.savedialog.show(initialdir=dir, initialfile=base)
+        if isinstance(filename, unicode):
+            filename = filename.encode(filesystemencoding)
+        return filename
 
     def updaterecentfileslist(self,filename):
         "Update recent file list on all editor windows"

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/NEWS.txt	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/NEWS.txt	Mon Apr 24 18:55:07 2006
@@ -1,7 +1,20 @@
-What's New in IDLE 1.2a0?
-=======================
+What's New in IDLE 1.2a1?
+=========================
+
+*Release date: 05-APR-2006*
+
+- Source file f.flush() after writing; trying to avoid lossage if user
+  kills GUI.
+
+- Options / Keys / Advanced dialog made functional.  Also, allow binding
+  of 'movement' keys.
+
+- 'syntax' patch adds improved calltips and a new class attribute listbox.
+  MultiCall module allows binding multiple actions to an event.
+  Patch 906702 Noam Raphael
 
-*Release date: XX-XXX-2005*
+- Better indentation after first line of string continuation.
+  IDLEfork Patch 681992, Noam Raphael
 
 - Fixed CodeContext alignment problem, following suggestion from Tal Einat.
 
@@ -60,7 +73,7 @@
 
 - Improve error handling when .idlerc can't be created (warn and exit).
 
-- The GUI was hanging if the shell window was closed while a raw_input() 
+- The GUI was hanging if the shell window was closed while a raw_input()
   was pending.  Restored the quit() of the readline() mainloop().
   http://mail.python.org/pipermail/idle-dev/2004-December/002307.html
 

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/ToolTip.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/ToolTip.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/ToolTip.py	Mon Apr 24 18:55:07 2006
@@ -83,7 +83,7 @@
     b.pack()
     root.update()
     tip = ListboxToolTip(b, ["Hello", "world"])
+    root.mainloop()
 
-    # root.mainloop() # not in idle
-
-main()
+if __name__ == '__main__':
+    main()

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/config-extensions.def
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/config-extensions.def	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/config-extensions.def	Mon Apr 24 18:55:07 2006
@@ -70,7 +70,7 @@
 
 [AutoComplete]
 enable=1
-popupwait=0
+popupwait=2000
 [AutoComplete_cfgBindings]
 force-open-completions=<Control-Key-space>
 [AutoComplete_bindings]

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/idlever.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/idlever.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/idlever.py	Mon Apr 24 18:55:07 2006
@@ -1 +1 @@
-IDLE_VERSION = "1.2a0"
+IDLE_VERSION = "1.2a1"

Modified: python/branches/IDLE-syntax-branch/Lib/idlelib/keybindingDialog.py
==============================================================================
--- python/branches/IDLE-syntax-branch/Lib/idlelib/keybindingDialog.py	(original)
+++ python/branches/IDLE-syntax-branch/Lib/idlelib/keybindingDialog.py	Mon Apr 24 18:55:07 2006
@@ -26,12 +26,13 @@
         self.result=''
         self.keyString=StringVar(self)
         self.keyString.set('')
-        self.SetModifiersForPlatform()
+        self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label
         self.modifier_vars = []
         for modifier in self.modifiers:
             variable = StringVar(self)
             variable.set('')
             self.modifier_vars.append(variable)
+        self.advanced = False
         self.CreateWidgets()
         self.LoadFinalKeyList()
         self.withdraw() #hide while setting geometry
@@ -136,7 +137,7 @@
             self.modifiers = ['Shift', 'Control', 'Option', 'Command']
         else:
             self.modifiers = ['Control', 'Alt', 'Shift']
-        self.modifier_label = {'Control': 'Ctrl'}
+        self.modifier_label = {'Control': 'Ctrl'} # short name
 
     def ToggleLevel(self):
         if  self.buttonLevel.cget('text')[:8]=='Advanced':
@@ -145,11 +146,13 @@
             self.frameKeySeqAdvanced.lift()
             self.frameHelpAdvanced.lift()
             self.entryKeysAdvanced.focus_set()
+            self.advanced = True
         else:
             self.ClearKeySeq()
             self.buttonLevel.config(text='Advanced Key Binding Entry >>')
             self.frameKeySeqBasic.lift()
             self.frameControlsBasic.lift()
+            self.advanced = False
 
     def FinalKeySelected(self,event):
         self.BuildKeyString()
@@ -208,7 +211,7 @@
         return key
 
     def OK(self, event=None):
-        if self.KeysOK():
+        if self.advanced or self.KeysOK():  # doesn't check advanced string yet
             self.result=self.keyString.get()
             self.destroy()
 
@@ -217,7 +220,12 @@
         self.destroy()
 
     def KeysOK(self):
-        "Validity check on user's keybinding selection"
+        '''Validity check on user's 'basic' keybinding selection.
+
+        Doesn't check the string produced by the advanced dialog because
+        'modifiers' isn't set.
+
+        '''
         keys = self.keyString.get()
         keys.strip()
         finalKey = self.listKeysFinal.get(ANCHOR)
@@ -232,20 +240,19 @@
         elif not keys.endswith('>'):
             tkMessageBox.showerror(title=title, parent=self,
                                    message='Missing the final Key')
-        elif not modifiers and finalKey not in self.functionKeys:
+        elif (not modifiers
+              and finalKey not in self.functionKeys + self.moveKeys):
             tkMessageBox.showerror(title=title, parent=self,
                                    message='No modifier key(s) specified.')
         elif (modifiers == ['Shift']) \
                  and (finalKey not in
-                      self.functionKeys + ('Tab', 'Space')):
-            msg = 'The shift modifier by itself may not be used with' \
-                  ' this key symbol; only with F1-F12, Tab, or Space'
-            tkMessageBox.showerror(title=title, parent=self,
-                                   message=msg)
+                      self.functionKeys + self.moveKeys + ('Tab', 'Space')):
+            msg = 'The shift modifier by itself may not be used with'\
+                  ' this key symbol.'
+            tkMessageBox.showerror(title=title, parent=self, message=msg)
         elif keySequence in self.currentKeySequences:
             msg = 'This key combination is already in use.'
-            tkMessageBox.showerror(title=title, parent=self,
-                                   message=msg)
+            tkMessageBox.showerror(title=title, parent=self, message=msg)
         else:
             keysOK = True
         return keysOK


More information about the Python-checkins mailing list