本文整理汇总了Python中win32clipboard.SetClipboardText方法的典型用法代码示例。如果您正苦于以下问题:Python win32clipboard.SetClipboardText方法的具体用法?Python win32clipboard.SetClipboardText怎么用?Python win32clipboard.SetClipboardText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32clipboard
的用法示例。
在下文中一共展示了win32clipboard.SetClipboardText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stop_line_profiler
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def stop_line_profiler():
"""Stops the line profiler and prints the results"""
global _active_line_profiler
if not _active_line_profiler:
return
stream = StringIO()
_active_line_profiler.print_stats(stream=stream)
_active_line_profiler = None
# print the results to the log
print(stream.getvalue())
# and copy to the clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(stream.getvalue())
win32clipboard.CloseClipboard()
xlcAlert("Line Profiler Stopped\n"
"Results have been written to the log and clipboard.")
示例2: put
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def put(data):
if sys.platform == "win32":
import win32clipboard as clip
clip.OpenClipboard()
clip.EmptyClipboard()
clip.SetClipboardText(data, clip.CF_UNICODETEXT)
clip.CloseClipboard()
elif sys.platform.startswith("linux"):
import subprocess
proc = subprocess.Popen(("xsel", "-i", "-b", "-l", "/dev/null"),
stdin=subprocess.PIPE)
proc.stdin.write(data.encode("utf-8"))
proc.stdin.close()
proc.wait()
else:
raise RuntimeError("Unsupported platform")
示例3: write_to_paste_buffer
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def write_to_paste_buffer(txt):
win32clipboard.OpenClipboard(0)
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(txt)
win32clipboard.CloseClipboard()
示例4: setText
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def setText( self, text ):
"""
\remarks Sets the text hold by the clipboarc.
\param text <string>
\return <bool> success
"""
import win32clipboard
win32clipboard.OpenClipboard()
win32clipboard.SetClipboardText( text )
win32clipboard.CloseClipboard()
return True
示例5: clipboardCopyText
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def clipboardCopyText(self, text):
""" Set the provided text to the system clipboard so it can be pasted
This function is used because QApplication.clipboard sometimes deadlocks in some
applications like XSI.
Args:
text (str): Set the text in the paste buffer to this text.
"""
import win32clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(text)
win32clipboard.CloseClipboard()
示例6: stop_profiling
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def stop_profiling():
"""Stop the cProfile profiler and print the results"""
global _active_cprofiler
if not _active_cprofiler:
xlcAlert("No active profiler")
return
_active_cprofiler.disable()
# print the profiler stats
stream = StringIO()
stats = pstats.Stats(_active_cprofiler, stream=stream).sort_stats("cumulative")
stats.print_stats()
# print the results to the log
print(stream.getvalue())
# and copy to the clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(stream.getvalue())
win32clipboard.CloseClipboard()
_active_cprofiler = None
xlcAlert("cProfiler Stopped\n"
"Results have been written to the log and clipboard.")
# Current active line profiler
示例7: recv
# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardText [as 别名]
def recv(self, data):
try:
text = data.decode(self.session.server.codec)
win32clipboard.OpenClipboard(self.session.app.hwnd)
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(text)
win32clipboard.CloseClipboard()
except UnicodeError:
self.error('encoding error')
except pywintypes.error as e:
self.error('error: %r' % e)
return