Example #1
0
 def _update_commands(self):
     command_tree = self._get_commands()
     for new_cmd, old_cmd in izip(flattened_full_chain(command_tree),
                                  flattened_full_chain(self.command_tree)):
         old_cmd.name = new_cmd.name
         if isinstance(new_cmd, Command):
             old_cmd.description = new_cmd.description
Example #2
0
 def on_commands_changed(self, command_tree, accel_table):
     self._accel_table = accel_table
     self.SetAcceleratorTable(self._accel_table)
     for cmd in flattened_full_chain(command_tree):
         if isinstance(cmd, Command):
             menu_item = self.main_menu.FindItemById(cmd.ide)
             if menu_item is not None:
                 menu_item.SetItemLabel(cmd.name_and_shortcut)
                 menu_item.SetHelp(cmd.description)
         elif isinstance(cmd, CommandCategory):
             if hasattr(cmd, 'idx'):
                 self.main_menu.SetMenuLabel(cmd.idx, cmd.name)
             elif hasattr(cmd, 'ide'):
                 menu_item = self.main_menu.FindItemById(cmd.ide)
                 if menu_item is not None:
                     menu_item.SetItemLabel(cmd.name)
Example #3
0
 def test_flattened_full_chain(self):
     lst = [0, 1, [2, 3], [4, [5, 6]], [7]]
     flattened_lst = [0, 1, [2, 3], 2, 3, [4, [5, 6]], 4, [5, 6], 5, 6, [7], 7]
     self.assertEquals(flattened_lst, list(flattened_full_chain(lst)))