本文整理汇总了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.
示例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
示例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)