本文整理匯總了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)