[Idle-dev] CVS: idle NEWS.txt, 1.24, 1.25 PyShell.py, 1.78, 1.79 config-keys.def, 1.19, 1.20 configHandler.py, 1.31, 1.32 keybindingDialog.py, 1.10, 1.11

Kurt B. Kaiser kbk at users.sourceforge.net
Mon Nov 24 22:42:34 EST 2003


Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv26437

Modified Files:
	NEWS.txt PyShell.py config-keys.def configHandler.py 
	keybindingDialog.py 
Log Message:
Keybindings with the Shift modifier now work correctly.  So do bindings
which use the Space key.  Limit unmodified user keybindings to the
function keys.
Python Bug 775353, IDLEfork Bugs 755647, 761557

Improve error handling during startup if there's no Tkinter.

M NEWS.txt
M PyShell.py
M config-keys.def
M configHandler.py
M keybindingDialog.py

Also applied to Python IDLE.


Index: NEWS.txt
===================================================================
RCS file: /cvsroot/idlefork/idle/NEWS.txt,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** NEWS.txt	24 Nov 2003 03:08:08 -0000	1.24
--- NEWS.txt	25 Nov 2003 03:42:32 -0000	1.25
***************
*** 8,11 ****
--- 8,15 ----
  *Release date: XX-XXX-2003*
  
+ - Keybindings with the Shift modifier now work correctly.  So do bindings which
+   use the Space key.  Limit unmodified user keybindings to the function keys.
+   Python Bug 775353, IDLEfork Bugs 755647, 761557
+ 
  - After an exception, run.py was not setting the exception vector. Noam
    Raphael suggested correcting this so pdb's postmortem pm() would work. 

Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -r1.78 -r1.79
*** PyShell.py	10 Aug 2003 04:05:37 -0000	1.78
--- PyShell.py	25 Nov 2003 03:42:32 -0000	1.79
***************
*** 17,21 ****
  from code import InteractiveInterpreter
  
! from Tkinter import *
  import tkMessageBox
  
--- 17,26 ----
  from code import InteractiveInterpreter
  
! try:
!     from Tkinter import *
! except ImportError:
!     print>>sys.__stderr__, "** IDLE can't import Tkinter.  " \
!                            "Your Python may not be configured for Tk. **"
!     sys.exit(1)
  import tkMessageBox
  

Index: config-keys.def
===================================================================
RCS file: /cvsroot/idlefork/idle/config-keys.def,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** config-keys.def	18 May 2003 02:21:55 -0000	1.19
--- config-keys.def	25 Nov 2003 03:42:32 -0000	1.20
***************
*** 31,38 ****
  plain-newline-and-indent=<Control-Key-j>
  print-window=<Control-Key-p>
! redo=<Control-Shift-Key-z>
  remove-selection=<Key-Escape>
! save-copy-of-window-as-file=<Alt-Shift-Key-s>
! save-window-as-file=<Control-Shift-Key-s>
  save-window=<Control-Key-s>
  select-all=<Control-Key-a>
--- 31,38 ----
  plain-newline-and-indent=<Control-Key-j>
  print-window=<Control-Key-p>
! redo=<Control-Shift-Key-Z>
  remove-selection=<Key-Escape>
! save-copy-of-window-as-file=<Alt-Shift-Key-S>
! save-window-as-file=<Control-Shift-Key-S>
  save-window=<Control-Key-s>
  select-all=<Control-Key-a>
***************
*** 79,83 ****
  print-window=<Control-x><Control-Key-p>
  python-docs=<Control-Key-h>
! python-context-help=<Control-Shift-Key-h>
  redo=<Alt-Key-z> <Meta-Key-z>
  remove-selection=<Key-Escape>
--- 79,83 ----
  print-window=<Control-x><Control-Key-p>
  python-docs=<Control-Key-h>
! python-context-help=<Control-Shift-Key-H>
  redo=<Alt-Key-z> <Meta-Key-z>
  remove-selection=<Key-Escape>
***************
*** 129,135 ****
  plain-newline-and-indent=<Control-Key-j>
  print-window=<Command-Key-p>
! redo=<Shift-Command-Key-z>
  remove-selection=<Key-Escape>
! save-window-as-file=<Shift-Command-Key-s>
  save-window=<Command-Key-s>
  save-copy-of-window-as-file=<Option-Command-Key-s>
--- 129,135 ----
  plain-newline-and-indent=<Control-Key-j>
  print-window=<Command-Key-p>
! redo=<Shift-Command-Key-Z>
  remove-selection=<Key-Escape>
! save-window-as-file=<Shift-Command-Key-S>
  save-window=<Command-Key-s>
  save-copy-of-window-as-file=<Option-Command-Key-s>

Index: configHandler.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configHandler.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** configHandler.py	27 Jan 2003 02:36:18 -0000	1.31
--- configHandler.py	25 Nov 2003 03:42:32 -0000	1.32
***************
*** 532,536 ****
              '<<redo>>': ['<Control-y>'],
              '<<remove-selection>>': ['<Escape>'],
!             '<<save-copy-of-window-as-file>>': ['<Alt-Shift-s>'],
              '<<save-window-as-file>>': ['<Alt-s>'],
              '<<save-window>>': ['<Control-s>'],
--- 532,536 ----
              '<<redo>>': ['<Control-y>'],
              '<<remove-selection>>': ['<Escape>'],
!             '<<save-copy-of-window-as-file>>': ['<Alt-Shift-S>'],
              '<<save-window-as-file>>': ['<Alt-s>'],
              '<<save-window>>': ['<Control-s>'],

Index: keybindingDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/keybindingDialog.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** keybindingDialog.py	31 Dec 2002 16:03:23 -0000	1.10
--- keybindingDialog.py	25 Nov 2003 03:42:32 -0000	1.11
***************
*** 1,4 ****
  """
! dialog for building tkinter accelerator key bindings
  """
  from Tkinter import *
--- 1,4 ----
  """
! Dialog for building Tkinter accelerator key bindings
  """
  from Tkinter import *
***************
*** 50,56 ****
          frameButtons=Frame(self)
          frameButtons.pack(side=BOTTOM,fill=X)
!         self.buttonOk = Button(frameButtons,text='Ok',
!                 width=8,command=self.Ok)
!         self.buttonOk.grid(row=0,column=0,padx=5,pady=5)
          self.buttonCancel = Button(frameButtons,text='Cancel',
                  width=8,command=self.Cancel)
--- 50,56 ----
          frameButtons=Frame(self)
          frameButtons.pack(side=BOTTOM,fill=X)
!         self.buttonOK = Button(frameButtons,text='OK',
!                 width=8,command=self.OK)
!         self.buttonOK.grid(row=0,column=0,padx=5,pady=5)
          self.buttonCancel = Button(frameButtons,text='Cancel',
                  width=8,command=self.Cancel)
***************
*** 86,92 ****
              column += 1
          labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT,
!                 text="Select the desired modifier\n"+
!                      "keys above, and final key\n"+
!                      "from the list on the right.")
          labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W)
          self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10,
--- 86,96 ----
              column += 1
          labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT,
!                             text=\
!                             "Select the desired modifier keys\n"+
!                             "above, and the final key from the\n"+
!                             "list on the right.\n\n" +
!                             "Use upper case Symbols when using\n" +
!                             "the Shift modifier.  (Letters will be\n" +
!                             "converted automatically.)")
          labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W)
          self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10,
***************
*** 103,107 ****
          labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT,
                  text="Enter new binding(s) for  '"+self.action+"' :\n"+
!                 "(will not be checked for validity)")
          labelTitleAdvanced.pack(anchor=W)
          self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced,
--- 107,111 ----
          labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT,
                  text="Enter new binding(s) for  '"+self.action+"' :\n"+
!                 "(These bindings will not be checked for validity!)")
          labelTitleAdvanced.pack(anchor=W)
          self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced,
***************
*** 109,117 ****
          self.entryKeysAdvanced.pack(fill=X)
          labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT,
!             text="Key bindings are specified using tkinter key id's as\n"+
                   "in these samples: <Control-f>, <Shift-F2>, <F12>,\n"
!                  "<Control-space>, <Meta-less>, <Control-Alt-Shift-x>.\n\n"+
!                  "'Emacs style' multi-keystroke bindings are specified as\n"+
!                  "follows: <Control-x><Control-y> or <Meta-f><Meta-g>.\n\n"+
                   "Multiple separate bindings for one action should be\n"+
                   "separated by a space, eg., <Alt-v> <Meta-v>." )
--- 113,123 ----
          self.entryKeysAdvanced.pack(fill=X)
          labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT,
!             text="Key bindings are specified using Tkinter keysyms as\n"+
                   "in these samples: <Control-f>, <Shift-F2>, <F12>,\n"
!                  "<Control-space>, <Meta-less>, <Control-Alt-Shift-X>.\n"
!                  "Upper case is used when the Shift modifier is present!\n\n" +
!                  "'Emacs style' multi-keystroke bindings are specified as\n" +
!                  "follows: <Control-x><Control-y>, where the first key\n" +
!                  "is the 'do-nothing' keybinding.\n\n" +
                   "Multiple separate bindings for one action should be\n"+
                   "separated by a space, eg., <Alt-v> <Meta-v>." )
***************
*** 150,167 ****
  
      def BuildKeyString(self):
!         keyList=[]
!         modifiers=self.GetModifiers()
!         finalKey=self.listKeysFinal.get(ANCHOR)
!         if modifiers: modifiers[0]='<'+modifiers[0]
!         keyList=keyList+modifiers
          if finalKey:
!             if (not modifiers) and (finalKey not
!                     in self.alphanumKeys+self.punctuationKeys):
!                 finalKey='<'+self.TranslateKey(finalKey)
!             else:
!                 finalKey=self.TranslateKey(finalKey)
!             keyList.append(finalKey+'>')
!         keyStr=string.join(keyList,'-')
!         self.keyString.set(keyStr)
  
      def GetModifiers(self):
--- 156,165 ----
  
      def BuildKeyString(self):
!         keyList = modifiers = self.GetModifiers()
!         finalKey = self.listKeysFinal.get(ANCHOR)
          if finalKey:
!             finalKey = self.TranslateKey(finalKey, modifiers)
!             keyList.append(finalKey)
!         self.keyString.set('<' + string.join(keyList,'-') + '>')
  
      def GetModifiers(self):
***************
*** 192,198 ****
              (END,)+keys)
  
!     def TranslateKey(self,key):
!         #translate from key list value to tkinter key-id
!         translateDict={'~':'asciitilde','!':'exclam','@':'at','#':'numbersign',
                  '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk',
                  '(':'parenleft',')':'parenright','_':'underscore','-':'minus',
--- 190,197 ----
              (END,)+keys)
  
!     def TranslateKey(self, key, modifiers):
!         "Translate from keycap symbol to the Tkinter keysym"
!         translateDict = {'Space':'space',
!                 '~':'asciitilde','!':'exclam','@':'at','#':'numbersign',
                  '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk',
                  '(':'parenleft',')':'parenright','_':'underscore','-':'minus',
***************
*** 202,213 ****
                  '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next',
                  'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up',
!                 'Down Arrow': 'Down'}
          if key in translateDict.keys():
!             key=translateDict[key]
!         key='Key-'+key
          return key
  
!     def Ok(self, event=None):
!         if self.KeysOk():
              self.result=self.keyString.get()
              self.destroy()
--- 201,214 ----
                  '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next',
                  'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up',
!                 'Down Arrow': 'Down', 'Tab':'tab'}
          if key in translateDict.keys():
!             key = translateDict[key]
!         if 'Shift' in modifiers and key in string.ascii_lowercase:
!             key = key.upper()
!         key = 'Key-' + key
          return key
  
!     def OK(self, event=None):
!         if self.KeysOK():
              self.result=self.keyString.get()
              self.destroy()
***************
*** 217,254 ****
          self.destroy()
  
!     def KeysOk(self):
!         #simple validity check
!         keysOk=1
!         keys=self.keyString.get()
          keys.strip()
!         finalKey=self.listKeysFinal.get(ANCHOR)
!         modifiers=self.GetModifiers()
!         keySequence=keys.split()#make into a key sequence list for overlap check
!         if not keys: #no keys specified
!             tkMessageBox.showerror(title='Key Sequence Error',
!                     message='No keys specified.')
!             keysOk=0
!         elif not keys.endswith('>'): #no final key specified
!             tkMessageBox.showerror(title='Key Sequence Error',
!                     message='No final key specified.')
!             keysOk=0
!         elif (not modifiers) and (finalKey in
!                 self.alphanumKeys+self.punctuationKeys):
!             #modifier required
!             tkMessageBox.showerror(title='Key Sequence Error',
!                     message='No modifier key(s) specified.')
!             keysOk=0
!         elif (modifiers==['Shift']) and (finalKey not
!                 in self.functionKeys+('Tab',)):
!             #shift alone is only a useful modifier with a function key
!             tkMessageBox.showerror(title='Key Sequence Error',
!                     message='Shift alone is not a useful modifier '+
!                             'when used with this final key key.')
!             keysOk=0
!         elif keySequence in self.currentKeySequences: #keys combo already in use
!             tkMessageBox.showerror(title='Key Sequence Error',
!                     message='This key combination is already in use.')
!             keysOk=0
!         return keysOk
  
  if __name__ == '__main__':
--- 218,254 ----
          self.destroy()
  
!     def KeysOK(self):
!         "Validity check on user's keybinding selection"
!         keys = self.keyString.get()
          keys.strip()
!         finalKey = self.listKeysFinal.get(ANCHOR)
!         modifiers = self.GetModifiers()
!         # create a key sequence list for overlap check:
!         keySequence = keys.split()
!         keysOK = False
!         title = 'Key Sequence Error'
!         if not keys:
!             tkMessageBox.showerror(title=title, parent=self,
!                                    message='No keys specified.')
!         elif not keys.endswith('>'):
!             tkMessageBox.showerror(title=title, parent=self,
!                                    message='Missing the final Key')
!         elif not modifiers and finalKey not in self.functionKeys:
!             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)
!         elif keySequence in self.currentKeySequences:
!             msg = 'This key combination is already in use.'
!             tkMessageBox.showerror(title=title, parent=self,
!                                    message=msg)
!         else:
!             keysOK = True
!         return keysOK
  
  if __name__ == '__main__':




More information about the IDLE-dev mailing list