MCPcopy Index your code
hub / github.com/python/cpython / keys_ok

Method keys_ok

Lib/idlelib/config_key.py:236–265  ·  view source on GitHub ↗

Validity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set.

(self, keys)

Source from the content-addressed store, hash-verified

234 return
235
236 def keys_ok(self, keys):
237 """Validity check on user's 'basic' keybinding selection.
238
239 Doesn't check the string produced by the advanced dialog because
240 'modifiers' isn't set.
241 """
242 final_key = self.list_keys_final.get('anchor')
243 modifiers = self.get_modifiers()
244 title = self.keyerror_title
245 key_sequences = [key for keylist in self.current_key_sequences
246 for key in keylist]
247 if not keys.endswith('>'):
248 self.showerror(title, parent=self,
249 message='Missing the final Key')
250 elif (not modifiers
251 and final_key not in FUNCTION_KEYS + MOVE_KEYS):
252 self.showerror(title=title, parent=self,
253 message='No modifier key(s) specified.')
254 elif (modifiers == ['Shift']) \
255 and (final_key not in
256 FUNCTION_KEYS + MOVE_KEYS + ('Tab', 'Space')):
257 msg = 'The shift modifier by itself may not be used with'\
258 ' this key symbol.'
259 self.showerror(title=title, parent=self, message=msg)
260 elif keys in key_sequences:
261 msg = 'This key combination is already in use.'
262 self.showerror(title=title, parent=self, message=msg)
263 else:
264 return True
265 return False
266
267 def bind_ok(self, keys):
268 "Return True if Tcl accepts the new keys else show message."

Callers 6

okMethod · 0.95
test_keys_no_endingMethod · 0.80
test_keys_shift_badMethod · 0.80
test_keys_dupMethod · 0.80

Calls 4

get_modifiersMethod · 0.95
showerrorMethod · 0.95
getMethod · 0.45
endswithMethod · 0.45

Tested by 5

test_keys_no_endingMethod · 0.64
test_keys_shift_badMethod · 0.64
test_keys_dupMethod · 0.64