Switch amongst GUI input hooks by name.
351636
def enable_gui(gui=None, app=None):
        
        # Deferred import
        from pydev_ipython.inputhook import enable_gui as real_enable_gui
        try:
            return real_enable_gui(gui, app)
        except ValueError as e:
            raise UsageError("%s" % e)
900040
def handle_input(self, ncode, wparam, lparam):
        """"""
        x_pos = lparam.contents.x_pos
        y_pos = lparam.contents.y_pos
        data = lparam.contents.mousedata

        # This is how we can distinguish mouse 1 from mouse 2
        # extrainfo = lparam.contents.extrainfo
        # The way windows seems to do it is there is primary mouse
        # and all other mouses report as mouse 2

        # Also useful later will be to support the flags field
        # flags = lparam.contents.flags
        # This shows if the event was from a real device or whether it
        # was injected somehow via software

        self.emulate_mouse(wparam, x_pos, y_pos, data)

        # Give back control to Windows to wait for and process the
        # next event
        return ctypes.windll.user32.CallNextHookEx(
            self.hooked, ncode, wparam, lparam)
860198
def _run_hooks(self, name, module):
        
        hooks = self.post_load_hooks.pop(name, [])

        for hook in hooks:
            hook(module)
875466
def _change_state(name, action, expected, *args, **kwargs):
    '''
    
    '''
    pre = state(name)
    if action != 'restart' and pre == expected:
        return {'result': False,
                'state': {'old': expected, 'new': expected},
                'comment': ('Container \'{0}\' already {1}'
                            .format(name, expected))}
    _client_wrapper(action, name, *args, **kwargs)
    _clear_context()
    try:
        post = state(name)
    except CommandExecutionError:
        # Container doesn't exist anymore
        post = None
    ret = {'result': post == expected,
           'state': {'old': pre, 'new': post}}
    return ret
637064
def uninstall_handle_input(self):
        """"""
        if self.hooked is None:
            return
        ctypes.windll.user32.UnhookWindowsHookEx(self.hooked)
        self.hooked = None
1364309
def _prompt_username(prompt="Username: ", prefill=None):
    """"""
    if prefill:
        readline.set_startup_hook(lambda: readline.insert_text(prefill))

    try:
        return input(prompt).strip()
    except EOFError:
        print()
    finally:
        readline.set_startup_hook()
1182780
def _do(name, gnome_kwargs, preferences):
    '''
    
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    messages = []

    for pref in preferences:
        key = pref
        value = preferences[pref]

        if isinstance(value, bool):
            ftype = 'boolean'

            # need to convert boolean values to strings and make lowercase to
            # pass to gsettings
            value = six.text_type(value).lower()

        elif isinstance(value, int):
            ftype = 'int'
        elif isinstance(value, six.string_types):
            ftype = 'string'
        else:
            ftype = 'string'

        gnome_kwargs.update({'key': key, 'value': value})

        if _check_current_value(gnome_kwargs, value):
            messages.append('{0} is already set to {1}'.format(key, value))
        else:
            result = __salt__['gnome.set'](**gnome_kwargs)
            if result['retcode'] == 0:
                messages.append('Setting {0} to {1}'.format(key, value))
                ret['changes'][key] = '{0}:{1}'.format(key, value)
                ret['result'] = True
            else:
                messages.append(result['stdout'])
                ret['result'] = False

        ret['comment'] = ', '.join(messages)

    return ret
188955
def OnItemSelected(self, event):
        """"""

        value = event.m_itemIndex
        self.startIndex = value

        self.switching = True
        post_command_event(self, self.GridActionTableSwitchMsg, newtable=value)
        self.switching = False

        event.Skip()
371797
def keypress(self, event):
        """"""
        try:
            self.choice.set(self.shortcuts[event.keysym])
        except KeyError:
            # key not found (probably a bug, since we intend to catch
            # only events from shortcut keys, but ignore it anyway)
            pass
758918
def bind(cls):
        
        super(cls, cls).bind()

        cls.search_btn_el.bind("click", cls.start)
        cls.input_el.bind("keypress", func_on_enter(cls.start))
652998
def toggle_buttons(self):
        """"""
        all_types = self.all_types.get_value()
        self.idx_evt_type.setEnabled(not all_types)
900914
def remove_hook(self, key_name, hook_name):
        """"""
        kf = self.dct[key_name]
        if 'hooks' in kf:
            if hook_name in kf['hooks']:
                return kf['hooks'].pop(hook_name)
559692
def get_input(context, conf):
    
    name = conf['name']['value']
    prompt = conf['prompt']['value']
    default = conf['default']['value'] or conf['debug']['value']

    if context.submodule or context.inputs:
        value = context.inputs.get(name, default)
    elif not context.test:
        # we skip user interaction during tests
        raw = raw_input("%s (default=%s) " % (encode(prompt), encode(default)))
        value = raw or default
    else:
        value = default

    return value
1223428
def menu_callback(self, m):
        ''''''
        if m.returnkey.startswith('# '):
            cmd = m.returnkey[2:]
            if m.handler is not None:
                if m.handler_result is None:
                    return
                cmd += m.handler_result
            self.mpstate.functions.process_stdin(cmd)
        if m.returnkey == 'menuSettings':
            wxsettings.WXSettings(self.settings)
779012
private void switchToWindow(String key, String handleToKeep) {
        Context.addWindow(key, handleToKeep);
        Context.setMainWindow(key);
        Context.getDriver().switchTo().window(handleToKeep);
    }
406918
function UI (input, output) {
  this.rl = readline.createInterface({
    input: input || ttys.stdin,
    output: output || ttys.stdout
  })
  
  // Delegated events bind.
  this.onLine = (function onLine () {
    _events.line.apply(this, arguments)
  }).bind(this)
  
  this.onKeypress = (function onKeypress () {
    if (this.rl) {
      _events.keypress.apply(this, arguments)
    }
  }).bind(this)
  
  this.forceClose = this.forceClose.bind(this)
  
  this.rl.addListener('line', this.onLine)
  this.rl.input.addListener('keypress', this.onKeypress)
  
  this.rl.on('SIGINT', this.forceClose)
  process.on('exit', this.forceClose)
}
377624
def install_handle_input(self):
        """"""
        self.pointer = self.get_fptr()

        self.hooked = ctypes.windll.user32.SetWindowsHookExA(
            13,
            self.pointer,
            ctypes.windll.kernel32.GetModuleHandleW(None),
            0
        )
        if not self.hooked:
            return False
        return True