| 1109 | |
| 1110 | |
| 1111 | class KeysPage(Frame): |
| 1112 | |
| 1113 | def __init__(self, master, extpage): |
| 1114 | super().__init__(master) |
| 1115 | self.extpage = extpage |
| 1116 | self.cd = master.winfo_toplevel() |
| 1117 | self.create_page_keys() |
| 1118 | self.load_key_cfg() |
| 1119 | |
| 1120 | def create_page_keys(self): |
| 1121 | """Return frame of widgets for Keys tab. |
| 1122 | |
| 1123 | Enable users to provisionally change both individual and sets of |
| 1124 | keybindings (shortcut keys). Except for features implemented as |
| 1125 | extensions, keybindings are stored in complete sets called |
| 1126 | keysets. Built-in keysets in idlelib/config-keys.def are fixed |
| 1127 | as far as the dialog is concerned. Any keyset can be used as the |
| 1128 | base for a new custom keyset, stored in .idlerc/config-keys.cfg. |
| 1129 | |
| 1130 | Function load_key_cfg() initializes tk variables and keyset |
| 1131 | lists and calls load_keys_list for the current keyset. |
| 1132 | Radiobuttons builtin_keyset_on and custom_keyset_on toggle var |
| 1133 | keyset_source, which controls if the current set of keybindings |
| 1134 | are from a builtin or custom keyset. DynOptionMenus builtinlist |
| 1135 | and customlist contain lists of the builtin and custom keysets, |
| 1136 | respectively, and the current item from each list is stored in |
| 1137 | vars builtin_name and custom_name. |
| 1138 | |
| 1139 | Button delete_custom_keys invokes delete_custom_keys() to delete |
| 1140 | a custom keyset from idleConf.userCfg['keys'] and changes. Button |
| 1141 | save_custom_keys invokes save_as_new_key_set() which calls |
| 1142 | get_new_keys_name() and create_new_key_set() to save a custom keyset |
| 1143 | and its keybindings to idleConf.userCfg['keys']. |
| 1144 | |
| 1145 | Listbox bindingslist contains all of the keybindings for the |
| 1146 | selected keyset. The keybindings are loaded in load_keys_list() |
| 1147 | and are pairs of (event, [keys]) where keys can be a list |
| 1148 | of one or more key combinations to bind to the same event. |
| 1149 | Mouse button 1 click invokes on_bindingslist_select(), which |
| 1150 | allows button_new_keys to be clicked. |
| 1151 | |
| 1152 | So, an item is selected in listbindings, which activates |
| 1153 | button_new_keys, and clicking button_new_keys calls function |
| 1154 | get_new_keys(). Function get_new_keys() gets the key mappings from the |
| 1155 | current keyset for the binding event item that was selected. The |
| 1156 | function then displays another dialog, GetKeysDialog, with the |
| 1157 | selected binding event and current keys and allows new key sequences |
| 1158 | to be entered for that binding event. If the keys aren't |
| 1159 | changed, nothing happens. If the keys are changed and the keyset |
| 1160 | is a builtin, function get_new_keys_name() will be called |
| 1161 | for input of a custom keyset name. If no name is given, then the |
| 1162 | change to the keybinding will abort and no updates will be made. If |
| 1163 | a custom name is entered in the prompt or if the current keyset was |
| 1164 | already custom (and thus didn't require a prompt), then |
| 1165 | idleConf.userCfg['keys'] is updated in function create_new_key_set() |
| 1166 | with the change to the event binding. The item listing in bindingslist |
| 1167 | is updated with the new keys. Var keybinding is also set which invokes |
| 1168 | the callback function, var_changed_keybinding, to add the change to |
no outgoing calls
no test coverage detected
searching dependent graphs…