def _deferred_init_pymol_internals(_pymol): # set up some global session tasks if viewing.session_restore_views not in _pymol._session_restore_tasks: _pymol._session_restore_tasks.append(viewing.session_restore_views) if viewing.session_save_views not in _pymol._session_save_tasks: _pymol._session_save_tasks.append(viewing.session_save_views) if viewing.session_restore_scenes not in _pymol._session_restore_tasks: _pymol._session_restore_tasks.append(viewing.session_restore_scenes) if viewing.session_save_scenes not in _pymol._session_save_tasks: _pymol._session_save_tasks.append(viewing.session_save_scenes) if wizarding.session_restore_wizard not in _pymol._session_restore_tasks: _pymol._session_restore_tasks.append(wizarding.session_restore_wizard) if wizarding.session_save_wizard not in _pymol._session_save_tasks: _pymol._session_save_tasks.append(wizarding.session_save_wizard) # take care of some deferred initialization _pymol._view_dict_sc = Shortcut({}) _pymol._scene_dict_sc = Shortcut({})
def create_shortcut(ai_settings, screen, shortcuts, shortcut_number, row_number): shortcut = Shortcut(ai_settings, screen) shortcut_width = shortcut.rect.width shortcut.x = shortcut_width + 2 * shortcut_width * shortcut_number shortcut.rect.x = shortcut.x shortcut.rect.y = shortcut.rect.height + 2 * shortcut.rect.height * row_number shortcuts.add(shortcut)
def getAllShortcutsString(): # collection = client.db.shortcutDB #mongoDB database collection shortcuts = [] # list of shortcuts to be returned for entry in shortcutDB.find(): keys = entry["keys"] description = entry["description"] shortcutToAdd = Shortcut(keys, description) shortcuts.append(shortcutToAdd.getShortcut()) return shortcuts
def add_shortcut(): global shortcuts if request.json['url'] is not None: dst = request.json['url'] if not dst.startswith('http'): dst = 'http://' + dst shortcut = Shortcut(generate_id(), dst) shortcuts[shortcut.id] = shortcut return jsonify(shortcut.to_dict()) else: return "Unsupported Media Type ;)", 415
def __init__(self, menu_name, name, action=None, container=None, shortcut=None, icon=None, doc='', position=-1): """Initializes information needed to create actions.. :Parameters: menu_name The name of the menu where the new entry will be added. The menu is created if it does not exist. name The name of the new menu entry. The name may contain an accelerator key prefixed by an ampersand like ``New &Action``. If an accelerator is not specified, or the one requested is already taken, the next free key is selected. action The callable which will be called when a user does any of the associated UI actions. container The wxPython element containing the UI components associated with the ``action``. When any of the registered UI actions is executed, the ``action`` is called only if the ``container`` or any of its child components has focus. It is possible to make the ``action`` always active by using ``None`` as the ``container``. shortcut The keyboard shortcut associated to the ``action``. The ``shortcut`` must be a string constructed from optional modifiers (``Ctrl, Shift, Alt``) and the actual shortcut key separating the parts with a hyphen. The shortcut key can be either a single character or any of the `wx keycodes`__ without the ``WXK_`` prefix. Examples: ``Ctrl-C``, ``Shift-Ctrl-6``, ``Alt-Left``, ``F6``. icon The icon added to the toolbar as a toolbar button. It can be either a 16x16 bitmap or a string presenting one of the icons provided by `wxPython's ArtProvider`__ like ``ART_FILE_OPEN``. doc The documentation shown on the statusbar when selection is on the associated menu entry or toolbar button. position The positional value of an item in the menu. Provided for ordering Tools menu. Defaults to -1. __ http://docs.wxwidgets.org/stable/wx_keycodes.html#keycodes __ http://www.wxpython.org/docs/api/wx.ArtProvider-class.html """ MenuInfo.__init__(self) self.menu_name = menu_name self.name = name self.action = action self.container = container self.shortcut = Shortcut(shortcut) self._icon = None self._icon_source = icon self.doc = doc self._position = position
def _parse_shortcuts_from_name(name): if '(' in name: eventhandler_name, shortcuts = name.split('(', 1) shortcuts = shortcuts.split(')')[0] elements = shortcuts.split(' or ') name = '%s (%s)' % (eventhandler_name, ' or '.join( Shortcut(e).printable for e in elements)) return eventhandler_name, name return name, name
def create_fleet(ai_settings, screen, ship, shortcuts): shortcut = Shortcut(ai_settings, screen) number_shortcuts_x = get_number_shortcuts_x(ai_settings, shortcut.rect.width) number_rows = get_number_rows(ai_settings, ship.rect.height, shortcut.rect.height) #create first row of shortcuts for row_number in range(number_rows): for shortcut_number in range(number_shortcuts_x): create_shortcut(ai_settings, screen, shortcuts, shortcut_number, row_number)
# first we need to import a set of symbols into the local namespace from api import * # deferred initialization _deferred_init_pymol_internals(pymol) # now we create the command langauge import keywords keyword = keywords.get_command_keywords() kw_list = keyword.keys() keywords.fix_list(kw_list) kwhash = Shortcut(kw_list) keywords.fix_dict(keyword) # informational or API-only functions which don't exist in the # PyMOL command language namespace help_only = keywords.get_help_only_keywords() help_sc = Shortcut(keyword.keys() + help_only.keys()) # keyboard configuration import keyboard special = keyboard.get_special() shft_special = keyboard.get_shft_special()
from shortcut import Shortcut cmd = None button_code = { 'left': 0, 'middle': 1, 'right': 2, 'wheel': 3, 'double_left': 4, 'double_middle': 5, 'double_right': 6, 'single_left': 7, 'single_middle': 8, 'single_right': 9 } button_sc = Shortcut(button_code.keys()) but_mod_code = { 'none': 0, 'shft': 1, 'ctrl': 2, 'ctsh': 3, 'alt': 4, 'alsh': 5, 'ctal': 6, 'ctas': 7, } but_mod_sc = Shortcut(but_mod_code.keys()) but_act_code = {
""" Use this class for any tests relating to Shortcut class """ from shortcut import Shortcut keys = ['ctrl', 'c'] copy = Shortcut(keys, 'Copy text') print(copy.getHotKey()) print(copy.getKeys()) print(copy.getDescription())
from shortcut import Shortcut """ List of shortcut objects """ generalShortcutsDict = {} windowsShortcutsDict = {} fileExplorerShortcuts = {} # Shortcuts Database in module # General shortcuts selectAll = Shortcut(['Ctrl', 'A'], 'Select all items in a document or window') copy = Shortcut(['Ctrl', 'C'], 'Copy the selected item') refreshWindow = Shortcut(['Ctrl', 'R'], 'Refresh the active window') paste = Shortcut(['Ctrl', 'V'], 'Paste the selected item') cut = Shortcut(['Ctrl', 'X'], 'Cut the selected item') redo = Shortcut(['Ctrl', 'Y'], 'Redo an action') undo = Shortcut(['Ctrl', 'Z'], 'Undo an action') zoomIn = Shortcut(['Ctrl', '+'], 'Zoom in') zoomOut = Shortcut(['Ctrl', '-'], 'Zoom out') cursorToNextWord = Shortcut(['Ctrl', 'Right'], 'Move cursor to the beginning of the next word') cursorToPreviousWord = Shortcut( ['Ctrl', 'Left'], 'Move cursor to the beginning of the previous word') cursorToNextParagraph = Shortcut( ['Ctrl', 'Down'], 'Move cursor to the beginning of the next paragraph') cursorToPreviousParagraph = Shortcut( ['Ctrl', 'Up'], 'Move cursor to the beginning of the previous paragraph') switchBetweenAllTabs = Shortcut( ['Ctrl', 'Alt', 'Tab'],
def getShortcutByName(name): target = shortcutDB.find_one({"name": name}) keys = target["keys"] description = target["description"] shortcut = Shortcut(keys, description) return shortcut