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")
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")
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))
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))
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))
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))
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)
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)
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) ) )
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)))
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)))
def _prepareToWrite(self, value): return u"" if value is None else HotKeyParser.toString(value)
def _prepareToWrite (self, value): return u"" if value == None else HotKeyParser.toString (value)
def _prepareToWrite(self, val) -> str: return '' if val is None else HotKeyParser.toString(val)