当前位置: 首页>>代码示例>>Python>>正文


Python pyperclip.PyperclipException方法代码示例

本文整理汇总了Python中pyperclip.PyperclipException方法的典型用法代码示例。如果您正苦于以下问题:Python pyperclip.PyperclipException方法的具体用法?Python pyperclip.PyperclipException怎么用?Python pyperclip.PyperclipException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyperclip的用法示例。


在下文中一共展示了pyperclip.PyperclipException方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_source_code

# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import PyperclipException [as 别名]
def _get_source_code(code, code_file):
    if code is not None:
        code_str = code
    elif code_file is not None:
        with open(code_file) as fi:
            code_str = fi.read()
    else:
        try:
            code_str = pyperclip.paste()
        except pyperclip.PyperclipException:
            raise Exception(
                'Could not retrieve code from the clipboard. '
                'Try putting your code in a file and using '
                'the `code_file` parameter instead of using the clipboard.'
            )
    return code_str


# an "input chunk" includes all lines (including comments/empty lines) that
# come after the preceding python statement and before the python statement in
# this chunk. each chunk will be placed in a notebook cell. 
开发者ID:crew102,项目名称:reprexpy,代码行数:23,代码来源:reprex.py

示例2: _copy

# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import PyperclipException [as 别名]
def _copy(self):
        """
        Copy text from clipboard.

        :return: None
        """
        if self._block_copy_paste:  # Prevents multiple executions of event
            return False
        if self._password:  # Password cannot be copied
            return False

        try:
            if self._selection_surface:  # If text is selected
                copy(self._get_selected_text())
            else:  # Copy all text
                copy(self._input_string)
        except PyperclipException:
            pass

        self._block_copy_paste = True
        return True 
开发者ID:ppizarror,项目名称:pygame-menu,代码行数:23,代码来源:textinput.py

示例3: keypress

# 需要导入模块: import pyperclip [as 别名]
# 或者: from pyperclip import PyperclipException [as 别名]
def keypress(self, size, key):
        keymap = Store.instance.config['keymap']

        if key == keymap['delete_message']:
            urwid.emit_signal(self, 'delete_message', self, self.user_id, self.ts)
            return True
        elif key == keymap['edit_message']:
            urwid.emit_signal(self, 'edit_message', self, self.user_id, self.ts, self.original_text)
            return True
        elif key == keymap['go_to_profile']:
            urwid.emit_signal(self, 'go_to_profile', self.user_id)
            return True
        elif key == keymap['go_to_sidebar'] or key == keymap['cursor_left']:
            urwid.emit_signal(self, 'go_to_sidebar')
            return True
        elif key == keymap['quit_application']:
            urwid.emit_signal(self, 'quit_application')
            return True
        elif key == keymap['set_insert_mode']:
            urwid.emit_signal(self, 'set_insert_mode')
            return True
        elif key == keymap['yank_message']:
            try:
                pyperclip.copy(self.original_text)
            except pyperclip.PyperclipException:
                pass
            return True
        elif key == keymap['get_permalink']:
            # FIXME
            urwid.emit_signal(self, 'get_permalink', self, self.channel_id, self.ts)
        elif key == 'enter':
            browser_name = Store.instance.config['features']['browser']

            for item in self.markdown_text.markup:
                type, value = item

                if type == 'link' and re.compile(r'^https?://').search(value):
                    browser_instance = webbrowser if browser_name == '' else webbrowser.get(browser_name)
                    browser_instance.open(value, new=2)
                    break

        return super(Message, self).keypress(size, key) 
开发者ID:haskellcamargo,项目名称:sclack,代码行数:44,代码来源:message.py


注:本文中的pyperclip.PyperclipException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。