| 42 | |
| 43 | |
| 44 | class GetKeysFrame(Frame): |
| 45 | |
| 46 | # Dialog title for invalid key sequence |
| 47 | keyerror_title = 'Key Sequence Error' |
| 48 | |
| 49 | def __init__(self, parent, action, current_key_sequences): |
| 50 | """ |
| 51 | parent - parent of this dialog |
| 52 | action - the name of the virtual event these keys will be |
| 53 | mapped to |
| 54 | current_key_sequences - a list of all key sequence lists |
| 55 | currently mapped to virtual events, for overlap checking |
| 56 | """ |
| 57 | super().__init__(parent) |
| 58 | self['borderwidth'] = 2 |
| 59 | self['relief'] = 'sunken' |
| 60 | self.parent = parent |
| 61 | self.action = action |
| 62 | self.current_key_sequences = current_key_sequences |
| 63 | self.result = '' |
| 64 | self.key_string = StringVar(self) |
| 65 | self.key_string.set('') |
| 66 | # Set self.modifiers, self.modifier_label. |
| 67 | self.set_modifiers_for_platform() |
| 68 | self.modifier_vars = [] |
| 69 | for modifier in self.modifiers: |
| 70 | variable = StringVar(self) |
| 71 | variable.set('') |
| 72 | self.modifier_vars.append(variable) |
| 73 | self.advanced = False |
| 74 | self.create_widgets() |
| 75 | |
| 76 | def showerror(self, *args, **kwargs): |
| 77 | # Make testing easier. Replace in #30751. |
| 78 | messagebox.showerror(*args, **kwargs) |
| 79 | |
| 80 | def create_widgets(self): |
| 81 | # Basic entry key sequence. |
| 82 | self.frame_keyseq_basic = Frame(self, name='keyseq_basic') |
| 83 | self.frame_keyseq_basic.grid(row=0, column=0, sticky='nsew', |
| 84 | padx=5, pady=5) |
| 85 | basic_title = Label(self.frame_keyseq_basic, |
| 86 | text=f"New keys for '{self.action}' :") |
| 87 | basic_title.pack(anchor='w') |
| 88 | |
| 89 | basic_keys = Label(self.frame_keyseq_basic, justify='left', |
| 90 | textvariable=self.key_string, relief='groove', |
| 91 | borderwidth=2) |
| 92 | basic_keys.pack(ipadx=5, ipady=5, fill='x') |
| 93 | |
| 94 | # Basic entry controls. |
| 95 | self.frame_controls_basic = Frame(self) |
| 96 | self.frame_controls_basic.grid(row=1, column=0, sticky='nsew', padx=5) |
| 97 | |
| 98 | # Basic entry modifiers. |
| 99 | self.modifier_checkbuttons = {} |
| 100 | column = 0 |
| 101 | for modifier, variable in zip(self.modifiers, self.modifier_vars): |
no outgoing calls
no test coverage detected
searching dependent graphs…