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