|
| 1 | + |
1 | 2 | from tkinter.ttk import Entry |
2 | 3 | from tkinter import Menu |
3 | 4 | from utils import * |
@@ -36,47 +37,57 @@ def create_patterns_menu() -> Menu: |
36 | 37 | menu = Menu(tearoff=False,**MENU_COLOR_ARGS) |
37 | 38 | # The numbers below the following lines are indices of context menu commands |
38 | 39 | # which are used in context_menu_displayers.py module given to entryconfig method |
39 | | - menu.add_command(label='Add Pattern', command=CommandsObjects.patterns_menu_commands.add_pattern,accelerator='Ctrl+Shift+A') # 0 |
40 | | - menu.add_command(label='Insert Pattern',command=CommandsObjects.patterns_menu_commands.insert_pattern,accelerator='Ctrl+I') # 1 |
| 40 | + menu.add_command(label='Add Pattern', command=CommandsObjects.patterns_menu_commands.add_pattern, |
| 41 | + accelerator='Ctrl+Shift+A', underline=0) # 0 |
| 42 | + menu.add_command(label='Insert Pattern',command=CommandsObjects.patterns_menu_commands.insert_pattern, |
| 43 | + accelerator='Ctrl+I', underline=2) # 1 |
41 | 44 | menu.add_separator() # 2 |
42 | | - menu.add_command(label='Move Up', command = CommandsObjects.patterns_menu_commands.move_selected, accelerator='K') # 3 |
43 | | - menu.add_command(label='Move Down', command = lambda : CommandsObjects.patterns_menu_commands.move_selected(up = False), accelerator='J') # 4 |
| 45 | + menu.add_command(label='Move Up', command = CommandsObjects.patterns_menu_commands.move_selected, |
| 46 | + accelerator='K', underline=5) # 3 |
| 47 | + menu.add_command(label='Move Down', command = lambda : CommandsObjects.patterns_menu_commands.move_selected(up = False), |
| 48 | + accelerator='J', underline=5) # 4 |
44 | 49 | menu.add_separator() # 5 |
45 | | - menu.add_command(label='Edit selected', command=CommandsObjects.patterns_menu_commands.edit_selected,accelerator='F2') # 6 |
46 | | - menu.add_command(label='Delete selected', command=CommandsObjects.patterns_menu_commands.delete_selected,accelerator='Delete') # 7 |
47 | | - menu.add_command(label='Copy selected', command=CommandsObjects.patterns_menu_commands.copy_pattern,accelerator='Ctrl+C') # 8 |
48 | | - menu.add_command(label='Delete All', command=CommandsObjects.patterns_menu_commands.delete_all,accelerator='Ctrl+Shift+D') # 9 |
49 | | - menu.add_command(label='Copy All', command=lambda : CommandsObjects.patterns_menu_commands.copy_pattern(all=True),accelerator='Ctrl+Shift+C') # 10 |
| 50 | + menu.add_command(label='Edit selected', command=CommandsObjects.patterns_menu_commands.edit_selected, |
| 51 | + accelerator='F2', underline=0) # 6 |
| 52 | + menu.add_command(label='Delete selected', command=CommandsObjects.patterns_menu_commands.delete_selected, accelerator='Delete') # 7 |
| 53 | + menu.add_command(label='Copy selected', command=CommandsObjects.patterns_menu_commands.copy_pattern, |
| 54 | + accelerator='Ctrl+C', underline=0) # 8 |
| 55 | + menu.add_command(label='Delete All', command=CommandsObjects.patterns_menu_commands.delete_all, accelerator='Ctrl+Shift+D') # 9 |
| 56 | + menu.add_command(label='Copy All', command=lambda : CommandsObjects.patterns_menu_commands.copy_pattern(all=True), |
| 57 | + accelerator='Ctrl+Shift+C',underline=1) # 10 |
50 | 58 | menu.add_separator() # 11 |
51 | | - menu.add_command(label='Import from file', command=CommandsObjects.patterns_menu_commands.import_from_file,accelerator='Ctrl+Shift+I') # 12 |
52 | | - menu.add_command(label='Export to file', command=CommandsObjects.patterns_menu_commands.export_to_file,accelerator='Ctrl+E') # 13 |
| 59 | + menu.add_command(label='Import from file', command=CommandsObjects.patterns_menu_commands.import_from_file, |
| 60 | + accelerator='Ctrl+Shift+I', underline=0) # 12 |
| 61 | + menu.add_command(label='Export to file', command=CommandsObjects.patterns_menu_commands.export_to_file, |
| 62 | + accelerator='Ctrl+E', underline=1) # 13 |
53 | 63 | return menu |
54 | 64 |
|
55 | 65 | @staticmethod |
56 | 66 | def create_log_menu() -> Menu: |
57 | 67 | menu = Menu(tearoff=False,**MENU_COLOR_ARGS) |
58 | | - menu.add_command(label='Copy log',command=CommandsObjects.log_menu_commands.copy_log,accelerator='Ctrl+C') # 0 |
59 | | - menu.add_command(label='Clear log',command=CommandsObjects.log_menu_commands.clear_log,accelerator='Ctrl+D') # 1 |
| 68 | + menu.add_command(label='Copy log',command=CommandsObjects.log_menu_commands.copy_log,accelerator='Ctrl+C', underline=0) # 0 |
| 69 | + menu.add_command(label='Clear log',command=CommandsObjects.log_menu_commands.clear_log,accelerator='Ctrl+D', underline=1) # 1 |
60 | 70 | menu.add_separator() # 2 |
61 | | - menu.add_command(label=LOG_MODE[0],command=CommandsObjects.log_menu_commands.toggle_log) # 3 |
| 71 | + menu.add_command(label=LOG_MODE[0],command=CommandsObjects.log_menu_commands.toggle_log, underline=0) # 3 |
62 | 72 | return menu |
63 | 73 |
|
64 | 74 | @staticmethod |
65 | 75 | def create_entry_menu(widget : Entry, excel_var, is_file_entry : bool=True,is_output_file_entry : bool=True) -> Menu: |
66 | 76 | menu = Menu(tearoff=False,**MENU_COLOR_ARGS) |
67 | | - menu.add_command(label='Select All', accelerator='Ctrl+A',command=lambda : widget.select_range(0,'end')) # 0 |
68 | | - menu.add_command(label='Copy', accelerator='Ctrl+C',command=lambda : widget.event_generate('<<Copy>>')) # 1 |
69 | | - menu.add_command(label='Paste', accelerator='Ctrl+V',command=lambda : widget.event_generate('<<Paste>>')) # 2 |
70 | | - menu.add_command(label='Cut', accelerator='Ctrl+X',command=lambda : widget.event_generate('<<Cut>>')) # 3 |
| 77 | + menu.add_command(label='Select All', command=lambda : widget.select_range(0,'end'), accelerator='Ctrl+A', underline=7) # 0 |
| 78 | + menu.add_command(label='Copy', command=lambda : widget.event_generate('<<Copy>>'), accelerator='Ctrl+C', underline=0) # 1 |
| 79 | + menu.add_command(label='Paste', command=lambda : widget.event_generate('<<Paste>>'), accelerator='Ctrl+V', underline=0) # 2 |
| 80 | + menu.add_command(label='Cut', command=lambda : widget.event_generate('<<Cut>>'), accelerator='Ctrl+X', underline=2) # 3 |
71 | 81 | menu.add_separator() # 4 |
72 | | - menu.add_command(label='Clear',accelerator='Ctrl+Shift+C',command=lambda : widget.delete(0,'end')) # 5 |
| 82 | + menu.add_command(label='Clear', command=lambda : widget.delete(0,'end'), accelerator='Ctrl+Shift+C', underline=1) # 5 |
73 | 83 | if is_file_entry: |
74 | | - menu.add_command(label='Browse',command=lambda : browse_files(widget, not is_output_file_entry),accelerator='Ctrl+B') # 6 |
| 84 | + menu.add_command(label='Browse',command=lambda : browse_files(widget, not is_output_file_entry), accelerator='Ctrl+B', underline=0) # 6 |
75 | 85 | if is_output_file_entry: |
76 | 86 | menu.add_separator() # 7 |
77 | 87 | menu.add_radiobutton(label='Excel',variable=excel_var,value=True, |
78 | | - command=CommandsObjects.csv_excel_switch_functions.show_only_excel_required_widgets) # 8 |
| 88 | + command=CommandsObjects.csv_excel_switch_functions.show_only_excel_required_widgets, underline=0) # 8 |
79 | 89 |
|
80 | 90 | menu.add_radiobutton(label='CSV',variable=excel_var,value=False, |
81 | | - command=CommandsObjects.csv_excel_switch_functions.hide_only_excel_required_widgets) # 9 |
| 91 | + command=CommandsObjects.csv_excel_switch_functions.hide_only_excel_required_widgets, underline=1) # 9 |
82 | 92 | return menu |
| 93 | + |
0 commit comments