예제 #1
0
 def test_commands_created(self):
     w = BaseMainWindow(None, None)
         
     cmd1 = Command(1, 'Name1', 'Desc1', lambda: 1, [])
     cmd2 = Command(2, 'Name2', 'Desc2', lambda: 1, [])
     cat1 = CommandCategory('Cat1')
     cat2 = CommandCategory('Cat2')
     
     cat1.append(cmd1)
     cat1.append(cat2)
     cat2.append(cmd2)
     
     tree = [cat1]
     
     pub.sendMessage('commands.created', command_tree=tree)
     
     self.assertEqual(1, w.main_menu.MenuCount)
     self.assertEqual(2, w.main_menu.GetMenu(0).MenuItemCount)
     self.assertEqual(1, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.MenuItemCount)
     
     cmd1.name = 'Nome1'
     cmd1.description = 'Descricao1'
     cmd2.name = 'Nome2'
     cmd2.description = 'Descricao2'
     cat1.name = 'Categoria1'
     cat2.name = 'Categoria2'
     
     pub.sendMessage('commands.changed', command_tree=tree, accel_table=wx.AcceleratorTable([]))
     
     self.assertEqual(cat1.name, w.main_menu.GetMenuLabel(0))
     self.assertEqual(cmd1.name, w.main_menu.GetMenu(0).FindItemByPosition(0).ItemLabel)
     self.assertEqual(cat2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).ItemLabel)
     self.assertEqual(cmd2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.FindItemByPosition(0).ItemLabel)
예제 #2
0
파일: command.py 프로젝트: conradoplg/navi
    def _get_commands(self):
        commands = []

        note_cat = CommandCategory(_("&Note"))
        note_cat.append(
            Command(
                10001,
                _("&New..."),
                _("Create a new note"),
                self.control.notes.create_new,
                [Shortcut(wx.ACCEL_CTRL, ord("N"))],
            )
        )
        note_cat.append(
            Command(
                10005,
                _("&Open..."),
                _("Open a previously created note"),
                self.control.notes.open_note,
                [Shortcut(wx.ACCEL_CTRL, ord("O"))],
            )
        )
        note_cat.append(
            Command(
                10002,
                _("&Close"),
                _("Close the opened note"),
                self.control.notes.close_current,
                [Shortcut(wx.ACCEL_CTRL, ord("W"))],
            )
        )
        note_cat.append(
            Command(
                10006,
                _("Move &right"),
                _("Moved the opened note to the right"),
                partial(pub.sendMessage, "note.move_right"),
                [Shortcut(wx.ACCEL_CTRL | wx.ACCEL_SHIFT, wx.WXK_PAGEDOWN)],
            )
        )
        note_cat.append(
            Command(
                10007,
                _("Move &left"),
                _("Moved the opened note to the left"),
                partial(pub.sendMessage, "note.move_left"),
                [Shortcut(wx.ACCEL_CTRL | wx.ACCEL_SHIFT, wx.WXK_PAGEUP)],
            )
        )
        note_cat.append(None)
        note_cat.append(
            Command(
                10003,
                _("O&ptions..."),
                _("Open the application options"),
                self.control.open_options,
                [Shortcut(wx.ACCEL_NORMAL, wx.WXK_F4)],
            )
        )
        note_cat.append(None)
        note_cat.append(
            Command(
                10004, _("&Quit"), _("Quit the application"), self.control.quit, [Shortcut(wx.ACCEL_CTRL, ord("Q"))]
            )
        )
        commands.append(note_cat)

        edit_cat = CommandCategory(_("&Edit"))
        edit_cat.append(
            Command(
                30001,
                _("&Find"),
                _("Find some text in the current note"),
                self.control.find,
                [Shortcut(wx.ACCEL_CTRL, ord("F"))],
            )
        )
        edit_cat.append(
            Command(
                30002,
                _("&Delete line"),
                _("Delete the current line"),
                partial(pub.sendMessage, "note.edit.delete_line"),
                [Shortcut(wx.ACCEL_CTRL, ord("D"))],
            )
        )
        edit_cat.append(
            Command(
                30003,
                _("Du&plicate lines"),
                _("Duplicate (below) the current line or the selected lines below"),
                partial(pub.sendMessage, "note.edit.duplicate_lines"),
                [Shortcut(wx.ACCEL_ALT | wx.ACCEL_SHIFT, wx.WXK_DOWN)],
            )
        )
        edit_cat.append(
            Command(
                30004,
                _("Cop&y lines"),
                _("Copy (above) the current line or the selected lines below"),
                partial(pub.sendMessage, "note.edit.copy_lines"),
                [Shortcut(wx.ACCEL_ALT | wx.ACCEL_SHIFT, wx.WXK_UP)],
            )
        )
        edit_cat.append(
            Command(
                30005,
                _("Move lines do&wn"),
                _("Move the current line or the selected lines down"),
                partial(pub.sendMessage, "note.edit.move_lines_down"),
                [Shortcut(wx.ACCEL_ALT, wx.WXK_DOWN)],
            )
        )
        edit_cat.append(
            Command(
                30006,
                _("Move lines &up"),
                _("Move the current line or the selected lines up"),
                partial(pub.sendMessage, "note.edit.move_lines_up"),
                [Shortcut(wx.ACCEL_ALT, wx.WXK_UP)],
            )
        )
        commands.append(edit_cat)

        program_cat = CommandCategory(_("&Program"), hidden=True)
        program_cat.append(
            Command(
                20001,
                _("&Hide"),
                _("Minimize the program to the notification area"),
                self.control.hide,
                [Shortcut(wx.ACCEL_NORMAL, wx.WXK_ESCAPE)],
            )
        )
        commands.append(program_cat)

        return commands
예제 #3
0
 def _get_commands(self):
     cat = CommandCategory(self._name)
     cat.append(Command(IDE, self._name, self._desc, self.dummy,
                        [Shortcut(DEF_FLAGS, DEF_KEY_CODE)]))
     return [cat]