2002-01-12 05:48:02 -04:00
|
|
|
"""
|
2003-11-24 01:26:16 -04:00
|
|
|
Dialog for building Tkinter accelerator key bindings
|
2002-01-12 05:48:02 -04:00
|
|
|
"""
|
2018-12-30 16:30:09 -04:00
|
|
|
from tkinter import Toplevel, Listbox, Text, StringVar, TclError
|
2019-01-02 23:22:10 -04:00
|
|
|
from tkinter.ttk import Frame, Button, Checkbutton, Entry, Label, Scrollbar
|
2017-06-26 01:55:48 -03:00
|
|
|
from tkinter import messagebox
|
2008-02-23 14:30:17 -04:00
|
|
|
import string
|
2014-03-28 00:49:14 -03:00
|
|
|
import sys
|
2002-01-12 05:48:02 -04:00
|
|
|
|
2017-06-26 01:55:48 -03:00
|
|
|
|
2018-12-31 16:19:53 -04:00
|
|
|
FUNCTION_KEYS = ('F1', 'F2' ,'F3' ,'F4' ,'F5' ,'F6',
|
|
|
|
'F7', 'F8' ,'F9' ,'F10' ,'F11' ,'F12')
|
|
|
|
ALPHANUM_KEYS = tuple(string.ascii_lowercase + string.digits)
|
|
|
|
PUNCTUATION_KEYS = tuple('~!@#%^&*()_-+={}[]|;:,.<>/?')
|
|
|
|
WHITESPACE_KEYS = ('Tab', 'Space', 'Return')
|
|
|
|
EDIT_KEYS = ('BackSpace', 'Delete', 'Insert')
|
|
|
|
MOVE_KEYS = ('Home', 'End', 'Page Up', 'Page Down', 'Left Arrow',
|
|
|
|
'Right Arrow', 'Up Arrow', 'Down Arrow')
|
|
|
|
AVAILABLE_KEYS = (ALPHANUM_KEYS + PUNCTUATION_KEYS + FUNCTION_KEYS +
|
|
|
|
WHITESPACE_KEYS + EDIT_KEYS + MOVE_KEYS)
|
|
|
|
|
|
|
|
|
|
|
|
def translate_key(key, modifiers):
|
|
|
|
"Translate from keycap symbol to the Tkinter keysym."
|
|
|
|
mapping = {'Space':'space',
|
|
|
|
'~':'asciitilde', '!':'exclam', '@':'at', '#':'numbersign',
|
|
|
|
'%':'percent', '^':'asciicircum', '&':'ampersand',
|
|
|
|
'*':'asterisk', '(':'parenleft', ')':'parenright',
|
|
|
|
'_':'underscore', '-':'minus', '+':'plus', '=':'equal',
|
|
|
|
'{':'braceleft', '}':'braceright',
|
|
|
|
'[':'bracketleft', ']':'bracketright', '|':'bar',
|
|
|
|
';':'semicolon', ':':'colon', ',':'comma', '.':'period',
|
|
|
|
'<':'less', '>':'greater', '/':'slash', '?':'question',
|
|
|
|
'Page Up':'Prior', 'Page Down':'Next',
|
|
|
|
'Left Arrow':'Left', 'Right Arrow':'Right',
|
|
|
|
'Up Arrow':'Up', 'Down Arrow': 'Down', 'Tab':'Tab'}
|
|
|
|
key = mapping.get(key, key)
|
|
|
|
if 'Shift' in modifiers and key in string.ascii_lowercase:
|
|
|
|
key = key.upper()
|
|
|
|
return f'Key-{key}'
|
|
|
|
|
|
|
|
|
2002-01-18 20:29:54 -04:00
|
|
|
class GetKeysDialog(Toplevel):
|
2017-06-26 01:55:48 -03:00
|
|
|
|
|
|
|
# Dialog title for invalid key sequence
|
|
|
|
keyerror_title = 'Key Sequence Error'
|
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def __init__(self, parent, title, action, current_key_sequences,
|
2017-09-30 18:37:53 -03:00
|
|
|
*, _htest=False, _utest=False):
|
2002-01-18 21:30:56 -04:00
|
|
|
"""
|
2018-12-28 00:08:03 -04:00
|
|
|
parent - parent of this dialog
|
|
|
|
title - string which is the title of the popup dialog
|
2002-01-18 21:30:56 -04:00
|
|
|
action - string, the name of the virtual event these keys will be
|
|
|
|
mapped to
|
2018-12-28 00:08:03 -04:00
|
|
|
current_key_sequences - list, a list of all key sequence lists
|
|
|
|
currently mapped to virtual events, for overlap checking
|
2014-05-25 19:44:05 -03:00
|
|
|
_htest - bool, change box location when running htest
|
2018-12-28 00:08:03 -04:00
|
|
|
_utest - bool, do not wait when running unittest
|
2002-01-18 21:30:56 -04:00
|
|
|
"""
|
2002-01-12 05:48:02 -04:00
|
|
|
Toplevel.__init__(self, parent)
|
2018-12-28 00:08:03 -04:00
|
|
|
self.withdraw() # Hide while setting geometry.
|
2002-01-12 05:48:02 -04:00
|
|
|
self.configure(borderwidth=5)
|
2018-12-28 00:08:03 -04:00
|
|
|
self.resizable(height=False, width=False)
|
2002-01-12 05:48:02 -04:00
|
|
|
self.title(title)
|
|
|
|
self.transient(parent)
|
|
|
|
self.grab_set()
|
2018-12-28 00:08:03 -04:00
|
|
|
self.protocol("WM_DELETE_WINDOW", self.cancel)
|
2002-01-12 05:48:02 -04:00
|
|
|
self.parent = parent
|
2018-12-28 00:08:03 -04:00
|
|
|
self.action = action
|
|
|
|
self.current_key_sequences = current_key_sequences
|
2016-06-10 19:19:21 -03:00
|
|
|
self.result = ''
|
2018-12-28 00:08:03 -04:00
|
|
|
self.key_string = StringVar(self)
|
|
|
|
self.key_string.set('')
|
|
|
|
# Set self.modifiers, self.modifier_label.
|
|
|
|
self.set_modifiers_for_platform()
|
2002-09-28 21:23:08 -03:00
|
|
|
self.modifier_vars = []
|
|
|
|
for modifier in self.modifiers:
|
|
|
|
variable = StringVar(self)
|
|
|
|
variable.set('')
|
|
|
|
self.modifier_vars.append(variable)
|
2005-11-22 17:09:37 -04:00
|
|
|
self.advanced = False
|
2018-12-28 00:08:03 -04:00
|
|
|
self.create_widgets()
|
2002-01-12 05:48:02 -04:00
|
|
|
self.update_idletasks()
|
2014-05-25 19:44:05 -03:00
|
|
|
self.geometry(
|
|
|
|
"+%d+%d" % (
|
|
|
|
parent.winfo_rootx() +
|
|
|
|
(parent.winfo_width()/2 - self.winfo_reqwidth()/2),
|
|
|
|
parent.winfo_rooty() +
|
|
|
|
((parent.winfo_height()/2 - self.winfo_reqheight()/2)
|
|
|
|
if not _htest else 150)
|
2018-12-28 00:08:03 -04:00
|
|
|
) ) # Center dialog over parent (or below htest box).
|
2016-06-10 19:19:21 -03:00
|
|
|
if not _utest:
|
2018-12-28 00:08:03 -04:00
|
|
|
self.deiconify() # Geometry set, unhide.
|
2016-06-10 19:19:21 -03:00
|
|
|
self.wait_window()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2017-06-26 01:55:48 -03:00
|
|
|
def showerror(self, *args, **kwargs):
|
|
|
|
# Make testing easier. Replace in #30751.
|
|
|
|
messagebox.showerror(*args, **kwargs)
|
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def create_widgets(self):
|
2018-12-30 16:30:09 -04:00
|
|
|
self.frame = frame = Frame(self, borderwidth=2, relief='sunken')
|
|
|
|
frame.pack(side='top', expand=True, fill='both')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
frame_buttons = Frame(self)
|
2018-12-30 16:30:09 -04:00
|
|
|
frame_buttons.pack(side='bottom', fill='x')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
self.button_ok = Button(frame_buttons, text='OK',
|
|
|
|
width=8, command=self.ok)
|
|
|
|
self.button_ok.grid(row=0, column=0, padx=5, pady=5)
|
|
|
|
self.button_cancel = Button(frame_buttons, text='Cancel',
|
|
|
|
width=8, command=self.cancel)
|
|
|
|
self.button_cancel.grid(row=0, column=1, padx=5, pady=5)
|
|
|
|
|
|
|
|
# Basic entry key sequence.
|
2018-12-30 00:39:27 -04:00
|
|
|
self.frame_keyseq_basic = Frame(frame, name='keyseq_basic')
|
2018-12-30 16:30:09 -04:00
|
|
|
self.frame_keyseq_basic.grid(row=0, column=0, sticky='nsew',
|
2018-12-28 00:08:03 -04:00
|
|
|
padx=5, pady=5)
|
|
|
|
basic_title = Label(self.frame_keyseq_basic,
|
|
|
|
text=f"New keys for '{self.action}' :")
|
2018-12-30 16:30:09 -04:00
|
|
|
basic_title.pack(anchor='w')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
2018-12-30 16:30:09 -04:00
|
|
|
basic_keys = Label(self.frame_keyseq_basic, justify='left',
|
|
|
|
textvariable=self.key_string, relief='groove',
|
2018-12-28 00:08:03 -04:00
|
|
|
borderwidth=2)
|
2018-12-30 16:30:09 -04:00
|
|
|
basic_keys.pack(ipadx=5, ipady=5, fill='x')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Basic entry controls.
|
|
|
|
self.frame_controls_basic = Frame(frame)
|
2018-12-30 16:30:09 -04:00
|
|
|
self.frame_controls_basic.grid(row=1, column=0, sticky='nsew', padx=5)
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Basic entry modifiers.
|
2002-09-28 21:23:08 -03:00
|
|
|
self.modifier_checkbuttons = {}
|
|
|
|
column = 0
|
|
|
|
for modifier, variable in zip(self.modifiers, self.modifier_vars):
|
|
|
|
label = self.modifier_label.get(modifier, modifier)
|
2018-12-28 00:08:03 -04:00
|
|
|
check = Checkbutton(self.frame_controls_basic,
|
|
|
|
command=self.build_key_string, text=label,
|
|
|
|
variable=variable, onvalue=modifier, offvalue='')
|
2018-12-30 16:30:09 -04:00
|
|
|
check.grid(row=0, column=column, padx=2, sticky='w')
|
2002-09-28 21:23:08 -03:00
|
|
|
self.modifier_checkbuttons[modifier] = check
|
|
|
|
column += 1
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Basic entry help text.
|
2018-12-30 16:30:09 -04:00
|
|
|
help_basic = Label(self.frame_controls_basic, justify='left',
|
2018-12-28 00:08:03 -04:00
|
|
|
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.)")
|
2018-12-30 16:30:09 -04:00
|
|
|
help_basic.grid(row=1, column=0, columnspan=4, padx=2, sticky='w')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Basic entry key list.
|
|
|
|
self.list_keys_final = Listbox(self.frame_controls_basic, width=15,
|
2018-12-30 16:30:09 -04:00
|
|
|
height=10, selectmode='single')
|
2018-12-31 16:19:53 -04:00
|
|
|
self.list_keys_final.insert('end', *AVAILABLE_KEYS)
|
2018-12-28 00:08:03 -04:00
|
|
|
self.list_keys_final.bind('<ButtonRelease-1>', self.final_key_selected)
|
2018-12-30 16:30:09 -04:00
|
|
|
self.list_keys_final.grid(row=0, column=4, rowspan=4, sticky='ns')
|
2018-12-28 00:08:03 -04:00
|
|
|
scroll_keys_final = Scrollbar(self.frame_controls_basic,
|
2018-12-30 16:30:09 -04:00
|
|
|
orient='vertical',
|
2018-12-28 00:08:03 -04:00
|
|
|
command=self.list_keys_final.yview)
|
|
|
|
self.list_keys_final.config(yscrollcommand=scroll_keys_final.set)
|
2018-12-30 16:30:09 -04:00
|
|
|
scroll_keys_final.grid(row=0, column=5, rowspan=4, sticky='ns')
|
2018-12-28 00:08:03 -04:00
|
|
|
self.button_clear = Button(self.frame_controls_basic,
|
|
|
|
text='Clear Keys',
|
|
|
|
command=self.clear_key_seq)
|
|
|
|
self.button_clear.grid(row=2, column=0, columnspan=4)
|
|
|
|
|
|
|
|
# Advanced entry key sequence.
|
2018-12-30 00:39:27 -04:00
|
|
|
self.frame_keyseq_advanced = Frame(frame, name='keyseq_advanced')
|
2018-12-30 16:30:09 -04:00
|
|
|
self.frame_keyseq_advanced.grid(row=0, column=0, sticky='nsew',
|
2018-12-28 00:08:03 -04:00
|
|
|
padx=5, pady=5)
|
2018-12-30 16:30:09 -04:00
|
|
|
advanced_title = Label(self.frame_keyseq_advanced, justify='left',
|
2018-12-28 00:08:03 -04:00
|
|
|
text=f"Enter new binding(s) for '{self.action}' :\n" +
|
|
|
|
"(These bindings will not be checked for validity!)")
|
2018-12-30 16:30:09 -04:00
|
|
|
advanced_title.pack(anchor='w')
|
2018-12-28 00:08:03 -04:00
|
|
|
self.advanced_keys = Entry(self.frame_keyseq_advanced,
|
|
|
|
textvariable=self.key_string)
|
2018-12-30 16:30:09 -04:00
|
|
|
self.advanced_keys.pack(fill='x')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Advanced entry help text.
|
|
|
|
self.frame_help_advanced = Frame(frame)
|
2018-12-30 16:30:09 -04:00
|
|
|
self.frame_help_advanced.grid(row=1, column=0, sticky='nsew', padx=5)
|
|
|
|
help_advanced = Label(self.frame_help_advanced, justify='left',
|
2003-11-24 01:26:16 -04:00
|
|
|
text="Key bindings are specified using Tkinter keysyms as\n"+
|
2002-01-12 05:48:02 -04:00
|
|
|
"in these samples: <Control-f>, <Shift-F2>, <F12>,\n"
|
2003-11-24 01:26:16 -04:00
|
|
|
"<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" +
|
2002-01-12 05:48:02 -04:00
|
|
|
"Multiple separate bindings for one action should be\n"+
|
|
|
|
"separated by a space, eg., <Alt-v> <Meta-v>." )
|
2018-12-30 16:30:09 -04:00
|
|
|
help_advanced.grid(row=0, column=0, sticky='nsew')
|
2018-12-28 00:08:03 -04:00
|
|
|
|
|
|
|
# Switch between basic and advanced.
|
|
|
|
self.button_level = Button(frame, command=self.toggle_level,
|
|
|
|
text='<< Basic Key Binding Entry')
|
2018-12-30 16:30:09 -04:00
|
|
|
self.button_level.grid(row=2, column=0, stick='ew', padx=5, pady=5)
|
2018-12-28 00:08:03 -04:00
|
|
|
self.toggle_level()
|
2002-01-12 05:48:02 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def set_modifiers_for_platform(self):
|
2002-09-28 21:23:08 -03:00
|
|
|
"""Determine list of names of key modifiers for this platform.
|
|
|
|
|
|
|
|
The names are used to build Tk bindings -- it doesn't matter if the
|
2018-12-28 00:08:03 -04:00
|
|
|
keyboard has these keys; it matters if Tk understands them. The
|
2002-09-28 21:23:08 -03:00
|
|
|
order is also important: key binding equality depends on it, so
|
|
|
|
config-keys.def must use the same ordering.
|
|
|
|
"""
|
2014-03-28 00:49:14 -03:00
|
|
|
if sys.platform == "darwin":
|
2002-09-28 21:23:08 -03:00
|
|
|
self.modifiers = ['Shift', 'Control', 'Option', 'Command']
|
|
|
|
else:
|
|
|
|
self.modifiers = ['Control', 'Alt', 'Shift']
|
2018-12-28 00:08:03 -04:00
|
|
|
self.modifier_label = {'Control': 'Ctrl'} # Short name.
|
|
|
|
|
|
|
|
def toggle_level(self):
|
|
|
|
"Toggle between basic and advanced keys."
|
|
|
|
if self.button_level.cget('text').startswith('Advanced'):
|
|
|
|
self.clear_key_seq()
|
|
|
|
self.button_level.config(text='<< Basic Key Binding Entry')
|
|
|
|
self.frame_keyseq_advanced.lift()
|
|
|
|
self.frame_help_advanced.lift()
|
|
|
|
self.advanced_keys.focus_set()
|
2005-11-22 17:09:37 -04:00
|
|
|
self.advanced = True
|
2002-01-12 05:48:02 -04:00
|
|
|
else:
|
2018-12-28 00:08:03 -04:00
|
|
|
self.clear_key_seq()
|
|
|
|
self.button_level.config(text='Advanced Key Binding Entry >>')
|
|
|
|
self.frame_keyseq_basic.lift()
|
|
|
|
self.frame_controls_basic.lift()
|
2005-11-22 17:09:37 -04:00
|
|
|
self.advanced = False
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2018-12-30 00:39:27 -04:00
|
|
|
def final_key_selected(self, event=None):
|
2018-12-28 00:08:03 -04:00
|
|
|
"Handler for clicking on key in basic settings list."
|
|
|
|
self.build_key_string()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def build_key_string(self):
|
|
|
|
"Create formatted string of modifiers plus the key."
|
|
|
|
keylist = modifiers = self.get_modifiers()
|
2018-12-30 16:30:09 -04:00
|
|
|
final_key = self.list_keys_final.get('anchor')
|
2018-12-28 00:08:03 -04:00
|
|
|
if final_key:
|
2018-12-31 16:19:53 -04:00
|
|
|
final_key = translate_key(final_key, modifiers)
|
2018-12-28 00:08:03 -04:00
|
|
|
keylist.append(final_key)
|
|
|
|
self.key_string.set(f"<{'-'.join(keylist)}>")
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def get_modifiers(self):
|
|
|
|
"Return ordered list of modifiers that have been selected."
|
|
|
|
mod_list = [variable.get() for variable in self.modifier_vars]
|
|
|
|
return [mod for mod in mod_list if mod]
|
2002-01-12 05:48:02 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def clear_key_seq(self):
|
|
|
|
"Clear modifiers and keys selection."
|
2018-12-30 16:30:09 -04:00
|
|
|
self.list_keys_final.select_clear(0, 'end')
|
|
|
|
self.list_keys_final.yview('moveto', '0.0')
|
2002-09-28 21:23:08 -03:00
|
|
|
for variable in self.modifier_vars:
|
|
|
|
variable.set('')
|
2018-12-28 00:08:03 -04:00
|
|
|
self.key_string.set('')
|
|
|
|
|
|
|
|
def ok(self, event=None):
|
|
|
|
keys = self.key_string.get().strip()
|
2017-06-26 01:55:48 -03:00
|
|
|
if not keys:
|
|
|
|
self.showerror(title=self.keyerror_title, parent=self,
|
|
|
|
message="No key specified.")
|
|
|
|
return
|
2018-12-28 00:08:03 -04:00
|
|
|
if (self.advanced or self.keys_ok(keys)) and self.bind_ok(keys):
|
2017-06-26 01:55:48 -03:00
|
|
|
self.result = keys
|
2018-08-02 03:37:50 -03:00
|
|
|
self.grab_release()
|
2017-06-26 01:55:48 -03:00
|
|
|
self.destroy()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def cancel(self, event=None):
|
|
|
|
self.result = ''
|
2018-08-02 03:37:50 -03:00
|
|
|
self.grab_release()
|
2002-01-18 21:30:56 -04:00
|
|
|
self.destroy()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2018-12-28 00:08:03 -04:00
|
|
|
def keys_ok(self, keys):
|
|
|
|
"""Validity check on user's 'basic' keybinding selection.
|
2005-11-22 17:09:37 -04:00
|
|
|
|
|
|
|
Doesn't check the string produced by the advanced dialog because
|
|
|
|
'modifiers' isn't set.
|
2018-12-28 00:08:03 -04:00
|
|
|
"""
|
2018-12-30 16:30:09 -04:00
|
|
|
final_key = self.list_keys_final.get('anchor')
|
2018-12-28 00:08:03 -04:00
|
|
|
modifiers = self.get_modifiers()
|
2017-06-26 01:55:48 -03:00
|
|
|
title = self.keyerror_title
|
2018-12-28 00:08:03 -04:00
|
|
|
key_sequences = [key for keylist in self.current_key_sequences
|
2017-06-27 02:23:55 -03:00
|
|
|
for key in keylist]
|
2017-06-26 01:55:48 -03:00
|
|
|
if not keys.endswith('>'):
|
|
|
|
self.showerror(title, parent=self,
|
|
|
|
message='Missing the final Key')
|
2005-11-22 17:09:37 -04:00
|
|
|
elif (not modifiers
|
2018-12-31 16:19:53 -04:00
|
|
|
and final_key not in FUNCTION_KEYS + MOVE_KEYS):
|
2017-06-26 01:55:48 -03:00
|
|
|
self.showerror(title=title, parent=self,
|
|
|
|
message='No modifier key(s) specified.')
|
2003-11-24 01:26:16 -04:00
|
|
|
elif (modifiers == ['Shift']) \
|
2018-12-28 00:08:03 -04:00
|
|
|
and (final_key not in
|
2018-12-31 16:19:53 -04:00
|
|
|
FUNCTION_KEYS + MOVE_KEYS + ('Tab', 'Space')):
|
2005-11-22 17:09:37 -04:00
|
|
|
msg = 'The shift modifier by itself may not be used with'\
|
|
|
|
' this key symbol.'
|
2017-06-26 01:55:48 -03:00
|
|
|
self.showerror(title=title, parent=self, message=msg)
|
2017-06-27 02:23:55 -03:00
|
|
|
elif keys in key_sequences:
|
2003-11-24 01:26:16 -04:00
|
|
|
msg = 'This key combination is already in use.'
|
2017-06-26 01:55:48 -03:00
|
|
|
self.showerror(title=title, parent=self, message=msg)
|
2003-11-24 01:26:16 -04:00
|
|
|
else:
|
2018-12-28 00:08:03 -04:00
|
|
|
return True
|
|
|
|
return False
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2017-06-26 01:55:48 -03:00
|
|
|
def bind_ok(self, keys):
|
|
|
|
"Return True if Tcl accepts the new keys else show message."
|
|
|
|
try:
|
|
|
|
binding = self.bind(keys, lambda: None)
|
|
|
|
except TclError as err:
|
|
|
|
self.showerror(
|
|
|
|
title=self.keyerror_title, parent=self,
|
|
|
|
message=(f'The entered key sequence is not accepted.\n\n'
|
|
|
|
f'Error: {err}'))
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
self.unbind(keys, binding)
|
|
|
|
return True
|
|
|
|
|
2016-06-10 19:19:21 -03:00
|
|
|
|
2002-01-12 05:48:02 -04:00
|
|
|
if __name__ == '__main__':
|
2018-06-19 21:11:24 -03:00
|
|
|
from unittest import main
|
|
|
|
main('idlelib.idle_test.test_config_key', verbosity=2, exit=False)
|
2017-07-04 23:41:12 -03:00
|
|
|
|
2014-05-25 19:44:05 -03:00
|
|
|
from idlelib.idle_test.htest import run
|
|
|
|
run(GetKeysDialog)
|