Ejemplo n.º 1
0
    def testToString(self):
        self.assertEqual(HotKeyParser.toString(HotKey("A")), "A")
        self.assertEqual(HotKeyParser.toString(HotKey("F1")), "F1")

        self.assertEqual(HotKeyParser.toString(HotKey("A", ctrl=True)),
                         "Ctrl+A")

        self.assertEqual(HotKeyParser.toString(HotKey("A", shift=True)),
                         "Shift+A")

        self.assertEqual(HotKeyParser.toString(HotKey("A", alt=True)),
                         "Alt+A")

        self.assertEqual(HotKeyParser.toString(
            HotKey("A", ctrl=True, alt=True)),
            "Ctrl+Alt+A")

        self.assertEqual(HotKeyParser.toString(
            HotKey("A", ctrl=True, shift=True)),
            "Ctrl+Shift+A")

        self.assertEqual(HotKeyParser.toString(
            HotKey("A", alt=True, shift=True)),
            "Shift+Alt+A")

        self.assertEqual(HotKeyParser.toString(
            HotKey("A", ctrl=True, alt=True, shift=True)),
            "Ctrl+Shift+Alt+A")
Ejemplo n.º 2
0
    def testToString(self):
        self.assertEqual(HotKeyParser.toString(HotKey(u"A")), u"A")
        self.assertEqual(HotKeyParser.toString(HotKey(u"F1")), u"F1")

        self.assertEqual(HotKeyParser.toString(HotKey(u"A", ctrl=True)),
                         u"Ctrl+A")

        self.assertEqual(HotKeyParser.toString(HotKey(u"A", shift=True)),
                         u"Shift+A")

        self.assertEqual(HotKeyParser.toString(HotKey(u"A", alt=True)),
                         u"Alt+A")

        self.assertEqual(
            HotKeyParser.toString(HotKey(u"A", ctrl=True, alt=True)),
            u"Ctrl+Alt+A")

        self.assertEqual(
            HotKeyParser.toString(HotKey(u"A", ctrl=True, shift=True)),
            u"Ctrl+Shift+A")

        self.assertEqual(
            HotKeyParser.toString(HotKey(u"A", alt=True, shift=True)),
            u"Shift+Alt+A")

        self.assertEqual(
            HotKeyParser.toString(HotKey(u"A", ctrl=True, alt=True,
                                         shift=True)), u"Ctrl+Shift+Alt+A")
Ejemplo n.º 3
0
    def testParse4 (self):
        hotkey = HotKeyParser.fromString (u"Alt+A")

        self.assertEqual (hotkey.key, "A")
        self.assertFalse (hotkey.ctrl)
        self.assertFalse (hotkey.shift)
        self.assertTrue (hotkey.alt)
Ejemplo n.º 4
0
    def testParse13 (self):
        hotkey = HotKeyParser.fromString (u" Ctrl + F1 ")

        self.assertEqual (hotkey.key, u"F1")
        self.assertTrue (hotkey.ctrl)
        self.assertFalse (hotkey.shift)
        self.assertFalse (hotkey.alt)
Ejemplo n.º 5
0
    def testParse9 (self):
        hotkey = HotKeyParser.fromString (u"ShIfT+ALT+ctrl+F1")

        self.assertEqual (hotkey.key, "F1")
        self.assertTrue (hotkey.ctrl)
        self.assertTrue (hotkey.shift)
        self.assertTrue (hotkey.alt)
Ejemplo n.º 6
0
    def testParse9(self):
        hotkey = HotKeyParser.fromString(u"ShIfT+ALT+ctrl+F1")

        self.assertEqual(hotkey.key, "F1")
        self.assertTrue(hotkey.ctrl)
        self.assertTrue(hotkey.shift)
        self.assertTrue(hotkey.alt)
Ejemplo n.º 7
0
    def testParse13(self):
        hotkey = HotKeyParser.fromString(u" Ctrl + F1 ")

        self.assertEqual(hotkey.key, u"F1")
        self.assertTrue(hotkey.ctrl)
        self.assertFalse(hotkey.shift)
        self.assertFalse(hotkey.alt)
Ejemplo n.º 8
0
    def testParse8(self):
        hotkey = HotKeyParser.fromString("Ctrl++")

        self.assertEqual(hotkey.key, "+")
        self.assertTrue(hotkey.ctrl)
        self.assertFalse(hotkey.shift)
        self.assertFalse(hotkey.alt)
Ejemplo n.º 9
0
    def testParse8(self):
        hotkey = HotKeyParser.fromString("Ctrl++")

        self.assertEqual(hotkey.key, "+")
        self.assertTrue(hotkey.ctrl)
        self.assertFalse(hotkey.shift)
        self.assertFalse(hotkey.alt)
Ejemplo n.º 10
0
    def testParse4(self):
        hotkey = HotKeyParser.fromString(u"Alt+A")

        self.assertEqual(hotkey.key, "A")
        self.assertFalse(hotkey.ctrl)
        self.assertFalse(hotkey.shift)
        self.assertTrue(hotkey.alt)
Ejemplo n.º 11
0
    def testParse5(self):
        hotkey = HotKeyParser.fromString(u"Shift+Alt+Ctrl+F1")

        self.assertEqual(hotkey.key, "F1")
        self.assertTrue(hotkey.ctrl)
        self.assertTrue(hotkey.shift)
        self.assertTrue(hotkey.alt)
Ejemplo n.º 12
0
    def testParse7(self):
        hotkey = HotKeyParser.fromString(u"+")

        self.assertEqual(hotkey.key, u"+")
        self.assertFalse(hotkey.ctrl)
        self.assertFalse(hotkey.shift)
        self.assertFalse(hotkey.alt)
Ejemplo n.º 13
0
    def testParse5 (self):
        hotkey = HotKeyParser.fromString (u"Shift+Alt+Ctrl+F1")

        self.assertEqual (hotkey.key, "F1")
        self.assertTrue (hotkey.ctrl)
        self.assertTrue (hotkey.shift)
        self.assertTrue (hotkey.alt)
Ejemplo n.º 14
0
    def testParse7 (self):
        hotkey = HotKeyParser.fromString (u"+")

        self.assertEqual (hotkey.key, u"+")
        self.assertFalse (hotkey.ctrl)
        self.assertFalse (hotkey.shift)
        self.assertFalse (hotkey.alt)
Ejemplo n.º 15
0
    def _getMenuItemTitle (self, strid):
        hotkey = self.getHotKey (strid)
        title = self.getTitle (strid)

        if hotkey is None:
            return title

        return u"{0}\t{1}".format (title, HotKeyParser.toString (hotkey))
Ejemplo n.º 16
0
    def _getToolbarItemTitle (self, strid):
        hotkey = self.getHotKey (strid)
        title = self.getTitle (strid)

        if hotkey is None:
            return title

        return u"{0} ({1})".format (title, HotKeyParser.toString (hotkey))
Ejemplo n.º 17
0
    def _getMenuItemTitle(self, strid):
        hotkey = self.getHotKey(strid)
        title = self.getTitle(strid)

        if hotkey is None:
            return title

        return '{0}\t{1}'.format(title, HotKeyParser.toString(hotkey))
Ejemplo n.º 18
0
    def _getToolbarItemTitle (self, strid):
        hotkey = self.getHotKey (strid)
        title = self.getTitle (strid)

        if hotkey == None:
            return title

        return u"{0} ({1})".format (title, HotKeyParser.toString (hotkey))
Ejemplo n.º 19
0
 def _loadValue(self):
     """
     Получить значение. В производных классах этот метод переопределяется
     """
     if self.config.has_option(self.section, self.param):
         return HotKeyParser.fromString(
             self.config.get(self.section, self.param))
     else:
         raise ValueError('Use default hotkey')
Ejemplo n.º 20
0
    def _assertMenuItemExists (self, menu, title, hotkey):
        """
        Проверить, что в меню есть элемент с заголовком (title + '\t' + hotkey)
        """
        menuItemId = menu.FindItem (title)
        self.assertNotEqual (menuItemId, wx.NOT_FOUND)

        menuItem = menu.FindItemById (menuItemId)
        
        if hotkey != None:
            self.assertEqual (menuItem.GetItemLabel(), title + "\t" + HotKeyParser.toString (hotkey))
        else:
            self.assertEqual (menuItem.GetItemLabel(), title)
Ejemplo n.º 21
0
    def _assertMenuItemExists(self, menu, title, hotkey):
        """
        Проверить, что в меню есть элемент с заголовком(title + '\t' + hotkey)
        """
        menuItemId = menu.FindItem(title)
        self.assertNotEqual(menuItemId, wx.NOT_FOUND)

        menuItem = menu.FindItemById(menuItemId)

        if hotkey is not None:
            self.assertEqual(menuItem.GetItemLabel(),
                             title + "\t" + HotKeyParser.toString(hotkey))
        else:
            self.assertEqual(menuItem.GetItemLabel(), title)
Ejemplo n.º 22
0
    def testHotKeysDefaultToolBar (self):
        action = TestAction()
        hotkey = HotKey ("T", ctrl=True)
        toolbar = self.wnd.toolbars[self.wnd.PLUGINS_TOOLBAR_STR]
        image = "../test/images/save.png"

        self.actionController.register (action, hotkey=hotkey)
        self.assertEqual (self.actionController.getHotKey (action.stringId), hotkey)

        self.actionController.appendToolbarButton (action.stringId, 
                toolbar,
                image)

        self.assertEqual (self._getToolItemLabel (toolbar, action.stringId), 
                u"{0} ({1})".format (action.title, HotKeyParser.toString (hotkey) ) )
Ejemplo n.º 23
0
    def testHotKeysDefaultToolBar(self):
        action = ExampleAction()
        hotkey = HotKey("T", ctrl=True)
        toolbar = self.mainWindow.toolbars[TOOLBAR_PLUGINS]
        image = "testdata/images/save.png"

        self.actionController.register(action, hotkey=hotkey)
        self.assertEqual(self.actionController.getHotKey(action.stringId),
                         hotkey)

        self.actionController.appendToolbarButton(action.stringId, toolbar,
                                                  image)

        self.assertEqual(
            self._getToolItemLabel(toolbar, action.stringId),
            "{0} ({1})".format(action.title, HotKeyParser.toString(hotkey)))
Ejemplo n.º 24
0
    def testHotKeysDefaultToolBar(self):
        action = TestAction()
        hotkey = HotKey("T", ctrl=True)
        toolbar = self.wnd.toolbars[self.wnd.PLUGINS_TOOLBAR_STR]
        image = "../test/images/save.png"

        self.actionController.register(action, hotkey=hotkey)
        self.assertEqual(self.actionController.getHotKey(action.stringId),
                         hotkey)

        self.actionController.appendToolbarButton(action.stringId, toolbar,
                                                  image)

        self.assertEqual(
            self._getToolItemLabel(toolbar, action.stringId),
            u"{0} ({1})".format(action.title, HotKeyParser.toString(hotkey)))
Ejemplo n.º 25
0
 def _prepareToWrite(self, value):
     return u"" if value is None else HotKeyParser.toString(value)
Ejemplo n.º 26
0
 def _loadValue(self):
     """
     Получить значение. В производных классах этот метод переопределяется
     """
     return HotKeyParser.fromString(
         self.config.get(self.section, self.param))
Ejemplo n.º 27
0
 def _prepareToWrite (self, value):
     return u"" if value == None else HotKeyParser.toString (value)
Ejemplo n.º 28
0
 def _loadValue (self):
     """
     Получить значение. В производных классах этот метод переопределяется
     """
     return HotKeyParser.fromString (self.config.get (self.section, self.param))
Ejemplo n.º 29
0
 def testParseInvalid_04(self):
     self.assertIsNone(HotKeyParser.fromString("asdfasd Абырвалг"))
Ejemplo n.º 30
0
 def testParse6(self):
     self.assertIsNone(HotKeyParser.fromString(""))
Ejemplo n.º 31
0
 def _prepareToWrite(self, val) -> str:
     return '' if val is None else HotKeyParser.toString(val)
Ejemplo n.º 32
0
 def testParseInvalid_01(self):
     self.assertIsNone(HotKeyParser.fromString("Ctrl+"))
Ejemplo n.º 33
0
 def testParseInvalid_03(self):
     self.assertIsNone(HotKeyParser.fromString("Ctrl+Shift+Alt+"))