[Idle-dev] CVS: idle configDialog.py,1.23,1.24 keybindingDialog.py,1.2,1.3
Stephen M. Gava
elguavas@users.sourceforge.net
Fri, 18 Jan 2002 17:30:58 -0800
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv31355
Modified Files:
configDialog.py keybindingDialog.py
Log Message:
keybinding configuration
Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** configDialog.py 2002/01/19 00:29:03 1.23
--- configDialog.py 2002/01/19 01:30:56 1.24
***************
*** 596,601 ****
binding=self.listBindings.get(listIndex)
bindName=binding.split()[0] #first part, up to first space
! newKeys=GetKeysDialog(self,'Get New Keys',bindName)
! print newKeys.result
if newKeys.result: #new keys were specified
self.listBindings.delete(listIndex)
--- 596,602 ----
binding=self.listBindings.get(listIndex)
bindName=binding.split()[0] #first part, up to first space
! currentKeySet=idleConf.CurrentKeys()
! currentKeySequences=idleConf.GetKeys(currentKeySet).values()
! newKeys=GetKeysDialog(self,'Get New Keys',bindName,currentKeySequences)
if newKeys.result: #new keys were specified
self.listBindings.delete(listIndex)
Index: keybindingDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/keybindingDialog.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** keybindingDialog.py 2002/01/19 00:28:00 1.2
--- keybindingDialog.py 2002/01/19 01:30:56 1.3
***************
*** 7,11 ****
class GetKeysDialog(Toplevel):
! def __init__(self,parent,title,action):
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
--- 7,17 ----
class GetKeysDialog(Toplevel):
! def __init__(self,parent,title,action,currentKeySequences):
! """
! action - string, the name of the virtual event these keys will be
! mapped to
! currentKeys - list, a list of all key sequence lists currently mapped
! to virtual events, for overlap checking
! """
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
***************
*** 17,20 ****
--- 23,27 ----
self.parent = parent
self.action=action
+ self.currentKeySequences=currentKeySequences
self.result=''
self.keyString=StringVar(self)
***************
*** 192,195 ****
--- 199,211 ----
(END,)+keys)
+ def Ok(self, event=None):
+ if self.KeysOk():
+ self.result=self.keyString.get()
+ self.destroy()
+
+ def Cancel(self, event=None):
+ self.result=''
+ self.destroy()
+
def KeysOk(self):
#simple validity check
***************
*** 199,202 ****
--- 215,219 ----
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',
***************
*** 207,210 ****
--- 224,232 ----
message='No final key specified.')
keysOk=0
+ elif (not modifiers) and (finalKey not in self.functionKeys):
+ #modifier required if not a function key
+ tkMessageBox.showerror(title='Key Sequence Error',
+ message='No modifier key(s) specified.')
+ keysOk=0
elif (modifiers==['Shift']) and (finalKey not in self.functionKeys):
#shift alone is only a useful modifier with a function key
***************
*** 213,227 ****
'when used with a function key.')
keysOk=0
return keysOk
- def Ok(self, event=None):
- if self.KeysOk():
- self.result=self.keyString.get()
- self.destroy()
-
- def Cancel(self, event=None):
- self.result=''
- self.destroy()
-
if __name__ == '__main__':
#test the dialog
--- 235,244 ----
'when used with a function 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__':
#test the dialog
***************
*** 231,235 ****
#aboutDialog.AboutDialog(root,'About')
keySeq=''
! dlg=GetKeysDialog(root,'Get Keys','find-again')
print dlg.result
Button(root,text='Dialog',command=run).pack()
--- 248,252 ----
#aboutDialog.AboutDialog(root,'About')
keySeq=''
! dlg=GetKeysDialog(root,'Get Keys','find-again',[])
print dlg.result
Button(root,text='Dialog',command=run).pack()