Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/keybindingDialog.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | d31be8c9c8a2 |
| children |
| rev | line source |
|---|---|
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
1 """ |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
2 Dialog for building Tkinter accelerator key bindings |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
3 """ |
|
47130
ef4cca2d6171
Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents:
45471
diff
changeset
|
4 from tkinter import * |
|
ef4cca2d6171
Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents:
45471
diff
changeset
|
5 import tkinter.messagebox as tkMessageBox |
|
45471
7dd2c1746267
Merged revisions 60990-61002 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42725
diff
changeset
|
6 import string |
|
51552
7fa8b7a2f50a
Backport of r69532
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
47130
diff
changeset
|
7 from idlelib import macosxSupport |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
8 |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
9 class GetKeysDialog(Toplevel): |
|
21763
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
10 def __init__(self,parent,title,action,currentKeySequences): |
|
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
11 """ |
|
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
12 action - string, the name of the virtual event these keys will be |
|
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
13 mapped to |
|
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
14 currentKeys - list, a list of all key sequence lists currently mapped |
| 26959 | 15 to virtual events, for overlap checking |
|
21763
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
16 """ |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
17 Toplevel.__init__(self, parent) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
18 self.configure(borderwidth=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
19 self.resizable(height=FALSE,width=FALSE) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
20 self.title(title) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
21 self.transient(parent) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
22 self.grab_set() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
23 self.protocol("WM_DELETE_WINDOW", self.Cancel) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
24 self.parent = parent |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
25 self.action=action |
|
21763
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
26 self.currentKeySequences=currentKeySequences |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
27 self.result='' |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
28 self.keyString=StringVar(self) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
29 self.keyString.set('') |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
30 self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
31 self.modifier_vars = [] |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
32 for modifier in self.modifiers: |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
33 variable = StringVar(self) |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
34 variable.set('') |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
35 self.modifier_vars.append(variable) |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
36 self.advanced = False |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
37 self.CreateWidgets() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
38 self.LoadFinalKeyList() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
39 self.withdraw() #hide while setting geometry |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
40 self.update_idletasks() |
| 26959 | 41 self.geometry("+%d+%d" % |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
42 ((parent.winfo_rootx()+((parent.winfo_width()/2) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
43 -(self.winfo_reqwidth()/2)), |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
44 parent.winfo_rooty()+((parent.winfo_height()/2) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
45 -(self.winfo_reqheight()/2)) )) ) #centre dialog over parent |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
46 self.deiconify() #geometry set, unhide |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
47 self.wait_window() |
| 26959 | 48 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
49 def CreateWidgets(self): |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
50 frameMain = Frame(self,borderwidth=2,relief=SUNKEN) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
51 frameMain.pack(side=TOP,expand=TRUE,fill=BOTH) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
52 frameButtons=Frame(self) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
53 frameButtons.pack(side=BOTTOM,fill=X) |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
54 self.buttonOK = Button(frameButtons,text='OK', |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
55 width=8,command=self.OK) |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
56 self.buttonOK.grid(row=0,column=0,padx=5,pady=5) |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
57 self.buttonCancel = Button(frameButtons,text='Cancel', |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
58 width=8,command=self.Cancel) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
59 self.buttonCancel.grid(row=0,column=1,padx=5,pady=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
60 self.frameKeySeqBasic = Frame(frameMain) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
61 self.frameKeySeqAdvanced = Frame(frameMain) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
62 self.frameControlsBasic = Frame(frameMain) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
63 self.frameHelpAdvanced = Frame(frameMain) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
64 self.frameKeySeqAdvanced.grid(row=0,column=0,sticky=NSEW,padx=5,pady=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
65 self.frameKeySeqBasic.grid(row=0,column=0,sticky=NSEW,padx=5,pady=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
66 self.frameKeySeqBasic.lift() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
67 self.frameHelpAdvanced.grid(row=1,column=0,sticky=NSEW,padx=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
68 self.frameControlsBasic.grid(row=1,column=0,sticky=NSEW,padx=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
69 self.frameControlsBasic.lift() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
70 self.buttonLevel = Button(frameMain,command=self.ToggleLevel, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
71 text='Advanced Key Binding Entry >>') |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
72 self.buttonLevel.grid(row=2,column=0,stick=EW,padx=5,pady=5) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
73 labelTitleBasic = Label(self.frameKeySeqBasic, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
74 text="New keys for '"+self.action+"' :") |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
75 labelTitleBasic.pack(anchor=W) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
76 labelKeysBasic = Label(self.frameKeySeqBasic,justify=LEFT, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
77 textvariable=self.keyString,relief=GROOVE,borderwidth=2) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
78 labelKeysBasic.pack(ipadx=5,ipady=5,fill=X) |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
79 self.modifier_checkbuttons = {} |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
80 column = 0 |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
81 for modifier, variable in zip(self.modifiers, self.modifier_vars): |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
82 label = self.modifier_label.get(modifier, modifier) |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
83 check=Checkbutton(self.frameControlsBasic, |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
84 command=self.BuildKeyString, |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
85 text=label,variable=variable,onvalue=modifier,offvalue='') |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
86 check.grid(row=0,column=column,padx=2,sticky=W) |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
87 self.modifier_checkbuttons[modifier] = check |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
88 column += 1 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
89 labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT, |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
90 text=\ |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
91 "Select the desired modifier keys\n"+ |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
92 "above, and the final key from the\n"+ |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
93 "list on the right.\n\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
94 "Use upper case Symbols when using\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
95 "the Shift modifier. (Letters will be\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
96 "converted automatically.)") |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
97 labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
98 self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
99 selectmode=SINGLE) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
100 self.listKeysFinal.bind('<ButtonRelease-1>',self.FinalKeySelected) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
101 self.listKeysFinal.grid(row=0,column=4,rowspan=4,sticky=NS) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
102 scrollKeysFinal=Scrollbar(self.frameControlsBasic,orient=VERTICAL, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
103 command=self.listKeysFinal.yview) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
104 self.listKeysFinal.config(yscrollcommand=scrollKeysFinal.set) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
105 scrollKeysFinal.grid(row=0,column=5,rowspan=4,sticky=NS) |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
106 self.buttonClear=Button(self.frameControlsBasic, |
|
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
107 text='Clear Keys',command=self.ClearKeySeq) |
|
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
108 self.buttonClear.grid(row=2,column=0,columnspan=4) |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
109 labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
110 text="Enter new binding(s) for '"+self.action+"' :\n"+ |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
111 "(These bindings will not be checked for validity!)") |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
112 labelTitleAdvanced.pack(anchor=W) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
113 self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced, |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
114 textvariable=self.keyString) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
115 self.entryKeysAdvanced.pack(fill=X) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
116 labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT, |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
117 text="Key bindings are specified using Tkinter keysyms as\n"+ |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
118 "in these samples: <Control-f>, <Shift-F2>, <F12>,\n" |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
119 "<Control-space>, <Meta-less>, <Control-Alt-Shift-X>.\n" |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
120 "Upper case is used when the Shift modifier is present!\n\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
121 "'Emacs style' multi-keystroke bindings are specified as\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
122 "follows: <Control-x><Control-y>, where the first key\n" + |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
123 "is the 'do-nothing' keybinding.\n\n" + |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
124 "Multiple separate bindings for one action should be\n"+ |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
125 "separated by a space, eg., <Alt-v> <Meta-v>." ) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
126 labelHelpAdvanced.grid(row=0,column=0,sticky=NSEW) |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
127 |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
128 def SetModifiersForPlatform(self): |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
129 """Determine list of names of key modifiers for this platform. |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
130 |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
131 The names are used to build Tk bindings -- it doesn't matter if the |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
132 keyboard has these keys, it matters if Tk understands them. The |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
133 order is also important: key binding equality depends on it, so |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
134 config-keys.def must use the same ordering. |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
135 """ |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
136 import sys |
|
51552
7fa8b7a2f50a
Backport of r69532
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
47130
diff
changeset
|
137 if macosxSupport.runningAsOSXApp(): |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
138 self.modifiers = ['Shift', 'Control', 'Option', 'Command'] |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
139 else: |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
140 self.modifiers = ['Control', 'Alt', 'Shift'] |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
141 self.modifier_label = {'Control': 'Ctrl'} # short name |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
142 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
143 def ToggleLevel(self): |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
144 if self.buttonLevel.cget('text')[:8]=='Advanced': |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
145 self.ClearKeySeq() |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
146 self.buttonLevel.config(text='<< Basic Key Binding Entry') |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
147 self.frameKeySeqAdvanced.lift() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
148 self.frameHelpAdvanced.lift() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
149 self.entryKeysAdvanced.focus_set() |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
150 self.advanced = True |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
151 else: |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
152 self.ClearKeySeq() |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
153 self.buttonLevel.config(text='Advanced Key Binding Entry >>') |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
154 self.frameKeySeqBasic.lift() |
| 26959 | 155 self.frameControlsBasic.lift() |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
156 self.advanced = False |
| 26959 | 157 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
158 def FinalKeySelected(self,event): |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
159 self.BuildKeyString() |
| 26959 | 160 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
161 def BuildKeyString(self): |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
162 keyList = modifiers = self.GetModifiers() |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
163 finalKey = self.listKeysFinal.get(ANCHOR) |
| 26959 | 164 if finalKey: |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
165 finalKey = self.TranslateKey(finalKey, modifiers) |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
166 keyList.append(finalKey) |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40775
diff
changeset
|
167 self.keyString.set('<' + '-'.join(keyList) + '>') |
| 26959 | 168 |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
169 def GetModifiers(self): |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
170 modList = [variable.get() for variable in self.modifier_vars] |
|
53497
d31be8c9c8a2
Use of 'filter' in keybindingDialog.py was causing
Kurt B. Kaiser <kbk@shore.net>
parents:
51552
diff
changeset
|
171 return [mod for mod in modList if mod] |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
172 |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
173 def ClearKeySeq(self): |
|
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
174 self.listKeysFinal.select_clear(0,END) |
|
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
175 self.listKeysFinal.yview(MOVETO, '0.0') |
|
25478
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
176 for variable in self.modifier_vars: |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
177 variable.set('') |
|
8c95486301b3
Mac users now see correct modifiers in the Key Binding Entry window.
Tony Lownds <tony@lownds.com>
parents:
22127
diff
changeset
|
178 self.keyString.set('') |
| 26959 | 179 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
180 def LoadFinalKeyList(self): |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
181 #these tuples are also available for use in validity checks |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
182 self.functionKeys=('F1','F2','F2','F4','F5','F6','F7','F8','F9', |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
183 'F10','F11','F12') |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
184 self.alphanumKeys=tuple(string.ascii_lowercase+string.digits) |
|
21764
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
185 self.punctuationKeys=tuple('~!@#%^&*()_-+={}[]|;:,.<>/?') |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
186 self.whitespaceKeys=('Tab','Space','Return') |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
187 self.editKeys=('BackSpace','Delete','Insert') |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
188 self.moveKeys=('Home','End','Page Up','Page Down','Left Arrow', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
189 'Right Arrow','Up Arrow','Down Arrow') |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
190 #make a tuple of most of the useful common 'final' keys |
|
21764
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
191 keys=(self.alphanumKeys+self.punctuationKeys+self.functionKeys+ |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
192 self.whitespaceKeys+self.editKeys+self.moveKeys) |
|
29794
94e5d1b8f696
SF patch #768187: replace apply(f, args, kwds) with f(*args, **kwds)
Raymond Hettinger <python@rcn.com>
parents:
26959
diff
changeset
|
193 self.listKeysFinal.insert(END, *keys) |
| 26959 | 194 |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
195 def TranslateKey(self, key, modifiers): |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
196 "Translate from keycap symbol to the Tkinter keysym" |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
197 translateDict = {'Space':'space', |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
198 '~':'asciitilde','!':'exclam','@':'at','#':'numbersign', |
|
21764
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
199 '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
200 '(':'parenleft',')':'parenright','_':'underscore','-':'minus', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
201 '+':'plus','=':'equal','{':'braceleft','}':'braceright', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
202 '[':'bracketleft',']':'bracketright','|':'bar',';':'semicolon', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
203 ':':'colon',',':'comma','.':'period','<':'less','>':'greater', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
204 '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next', |
|
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
205 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up', |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35931
diff
changeset
|
206 'Down Arrow': 'Down', 'Tab':'Tab'} |
|
42725
fa9a40ef0780
Conform to py3k dict.{keys, items, values} with some advice from 2b3
Kurt B. Kaiser <kbk@shore.net>
parents:
41480
diff
changeset
|
207 if key in translateDict: |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
208 key = translateDict[key] |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
209 if 'Shift' in modifiers and key in string.ascii_lowercase: |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
210 key = key.upper() |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
211 key = 'Key-' + key |
|
21764
0110a0983e61
further work on keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21763
diff
changeset
|
212 return key |
| 26959 | 213 |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
214 def OK(self, event=None): |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
215 if self.advanced or self.KeysOK(): # doesn't check advanced string yet |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
216 self.result=self.keyString.get() |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
217 self.destroy() |
| 26959 | 218 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
219 def Cancel(self, event=None): |
|
21762
a1b0658293a7
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21711
diff
changeset
|
220 self.result='' |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
221 self.destroy() |
| 26959 | 222 |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
223 def KeysOK(self): |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
224 '''Validity check on user's 'basic' keybinding selection. |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
225 |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
226 Doesn't check the string produced by the advanced dialog because |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
227 'modifiers' isn't set. |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
228 |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
229 ''' |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
230 keys = self.keyString.get() |
|
21763
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
231 keys.strip() |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
232 finalKey = self.listKeysFinal.get(ANCHOR) |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
233 modifiers = self.GetModifiers() |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
234 # create a key sequence list for overlap check: |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
235 keySequence = keys.split() |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
236 keysOK = False |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
237 title = 'Key Sequence Error' |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
238 if not keys: |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
239 tkMessageBox.showerror(title=title, parent=self, |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
240 message='No keys specified.') |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
241 elif not keys.endswith('>'): |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
242 tkMessageBox.showerror(title=title, parent=self, |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
243 message='Missing the final Key') |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
244 elif (not modifiers |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
245 and finalKey not in self.functionKeys + self.moveKeys): |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
246 tkMessageBox.showerror(title=title, parent=self, |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
247 message='No modifier key(s) specified.') |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
248 elif (modifiers == ['Shift']) \ |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
249 and (finalKey not in |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
250 self.functionKeys + self.moveKeys + ('Tab', 'Space')): |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
251 msg = 'The shift modifier by itself may not be used with'\ |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
252 ' this key symbol.' |
|
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
253 tkMessageBox.showerror(title=title, parent=self, message=msg) |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
254 elif keySequence in self.currentKeySequences: |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
255 msg = 'This key combination is already in use.' |
|
35931
cf2b4c8ad1ad
1. Made advanced keybinding dialog functional.
Kurt B. Kaiser <kbk@shore.net>
parents:
31013
diff
changeset
|
256 tkMessageBox.showerror(title=title, parent=self, message=msg) |
|
31013
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
257 else: |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
258 keysOK = True |
|
270d59e346e6
Keybindings with the Shift modifier now work correctly. So do bindings
Kurt B. Kaiser <kbk@shore.net>
parents:
29794
diff
changeset
|
259 return keysOK |
| 26959 | 260 |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
261 if __name__ == '__main__': |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
262 #test the dialog |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
263 root=Tk() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
264 def run(): |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
265 keySeq='' |
|
21763
652dc51b5f83
keybinding configuration
Steven M. Gava <elguavas@python.net>
parents:
21762
diff
changeset
|
266 dlg=GetKeysDialog(root,'Get Keys','find-again',[]) |
|
40775
4cdf21a0dbbc
Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
267 print(dlg.result) |
|
21711
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
268 Button(root,text='Dialog',command=run).pack() |
|
437393e780cb
key binding handling dialog
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
269 root.mainloop() |
