cca
changeset 77:c18bb7548057
shortcuts for action, file
author | Ilia |
---|---|
date | Sun, 12 Dec 2010 22:48:44 +0300 |
parents | cb06850ea930 |
children | f0cce52da744 |
files | Interface.py |
diffstat | 1 files changed, 30 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/Interface.py Sun Dec 12 13:54:51 2010 +0300 1.2 +++ b/Interface.py Sun Dec 12 22:48:44 2010 +0300 1.3 @@ -94,12 +94,12 @@ 1.4 self.cell_size = self.cell_size - zoom_rate 1.5 self.draw() 1.6 1.7 - def slower(self, speed_rate=2, event=None): 1.8 + def slower(self, event=None, speed_rate=2): 1.9 self.stop() 1.10 self.delay = self.delay*speed_rate 1.11 self.start() 1.12 1.13 - def faster(self, speed_rate=2, event=None): 1.14 + def faster(self, event=None, speed_rate=2): 1.15 self.stop() 1.16 self.delay = self.delay / speed_rate 1.17 if self.delay == 0: 1.18 @@ -489,6 +489,8 @@ 1.19 automata.st_sym[state.symbol] = state 1.20 self.keys[state.key] = index 1.21 1.22 + def exit(self, event=None): 1.23 + pass 1.24 1.25 1.26 root = Tk() 1.27 @@ -672,29 +674,42 @@ 1.28 root.config(menu=menubar) 1.29 1.30 menu_file = Menu(menubar) 1.31 -menu_file.add_command(label="New", command=handlers.new_file) 1.32 -menu_file.add_command(label="Open...", command=handlers.open_file) 1.33 +menu_file.add_command(label="New", command=handlers.new_file, accelerator="Ctrl+N") 1.34 +menu_file.bind_all("<Control-n>", handlers.new_file) 1.35 +menu_file.add_command(label="Open...", command=handlers.open_file, accelerator="Ctrl+O") 1.36 +menu_file.bind_all("<Control-o>", handlers.open_file) 1.37 menu_file.add_command(label="Save...", command=handlers.save_file, accelerator="Ctrl+S") 1.38 menu_file.bind_all("<Control-s>", handlers.save_file) 1.39 menu_file.add_separator() 1.40 -menu_file.add_command(label="Exit", command=root.destroy) 1.41 +menu_file.add_command(label="Exit", command=handlers.exit, accelerator="Ctrl+Q") 1.42 +menu_file.bind_all("<Control-q>", handlers.exit) 1.43 menubar.add_cascade(label="File", menu=menu_file) 1.44 1.45 menu_action = Menu(menubar) 1.46 -menu_action.add_command(label="Start", command=handlers.start) 1.47 -menu_action.add_command(label="Stop", command=handlers.stop) 1.48 -menu_action.add_command(label="Next Step", command=handlers.next_step) 1.49 +menu_action.add_command(label="Start", command=handlers.start, accelerator="Ctrl+G") 1.50 +menu_action.bind_all("<Control-g>", handlers.start) 1.51 +menu_action.add_command(label="Stop", command=handlers.stop, accelerator="Ctrl+F") 1.52 +menu_action.bind_all("<Control-f>", handlers.stop) 1.53 +menu_action.add_command(label="Next Step", command=handlers.next_step, accelerator="Space") 1.54 +menu_action.bind_all("<space>", handlers.next_step) 1.55 menu_action.add_separator() 1.56 -menu_action.add_command(label="Increase speed", command=handlers.faster) 1.57 -menu_action.add_command(label="Decrease speed", command=handlers.slower) 1.58 +menu_action.add_command(label="Increase speed", command=handlers.faster, accelerator="Alt+F") 1.59 +menu_action.bind_all("<Alt-f>", handlers.faster) 1.60 +menu_action.add_command(label="Decrease speed", command=handlers.slower, accelerator="Alt+S") 1.61 +menu_action.bind_all("<Alt-s>", handlers.slower) 1.62 menu_action.add_separator() 1.63 -menu_action.add_command(label="Zoom In", command=handlers.zoom_in) 1.64 -menu_action.add_command(label="Zoom Out", command=handlers.zoom_out) 1.65 +menu_action.add_command(label="Zoom In", command=handlers.zoom_in, accelerator="Ctrl+Z") 1.66 +menu_action.bind_all("<Control-z>", handlers.zoom_in) 1.67 +menu_action.add_command(label="Zoom Out", command=handlers.zoom_out, accelerator="Ctrl+X") 1.68 +menu_action.bind_all("<Control-x>", handlers.zoom_out) 1.69 menu_action.add_separator() 1.70 -menu_action.add_command(label="Clean field", command=handlers.clean_field) 1.71 -menu_action.add_command(label="Fill randomly", command=handlers.fill_randomly) 1.72 +menu_action.add_command(label="Clean field", command=handlers.clean_field, accelerator="Ctrl+C") 1.73 +menu_action.bind_all("<Control-c>", handlers.clean_field) 1.74 +menu_action.add_command(label="Fill randomly", command=handlers.fill_randomly, accelerator="Ctrl+R") 1.75 +menu_action.bind_all("<Control-r>", handlers.fill_randomly) 1.76 menu_action.add_separator() 1.77 -menu_action.add_command(label="Change size",command=handlers.show_size_window) 1.78 +menu_action.add_command(label="Change size",command=handlers.show_size_window, accelerator="Ctrl+D") 1.79 +menu_action.bind_all("<Control-d>", handlers.show_size_window) 1.80 menubar.add_cascade(label="Action", menu=menu_action) 1.81 1.82 menubar.add_command(label="Automata", command=handlers.show_automata_window)