本文整理汇总了Python中gtk.Clipboard方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.Clipboard方法的具体用法?Python gtk.Clipboard怎么用?Python gtk.Clipboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.Clipboard方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_gtk_clipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def init_gtk_clipboard():
global gtk
import gtk
def copy_gtk(text):
global cb
text = _stringifyText(text) # Converts non-str values to str.
cb = gtk.Clipboard()
cb.set_text(text)
cb.store()
def paste_gtk():
clipboardContents = gtk.Clipboard().wait_for_text()
# for python 2, returns None if the clipboard is blank.
if clipboardContents is None:
return ''
else:
return clipboardContents
return copy_gtk, paste_gtk
示例2: init_wsl_clipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def init_wsl_clipboard():
def copy_wsl(text):
text = _stringifyText(text) # Converts non-str values to str.
p = subprocess.Popen(['clip.exe'],
stdin=subprocess.PIPE, close_fds=True)
p.communicate(input=text.encode(ENCODING))
def paste_wsl():
p = subprocess.Popen(['powershell.exe', '-command', 'Get-Clipboard'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
stdout, stderr = p.communicate()
# WSL appends "\r\n" to the contents.
return stdout[:-2].decode(ENCODING)
return copy_wsl, paste_wsl
# Automatic detection of clipboard mechanisms and importing is done in deteremine_clipboard():
示例3: init_gtk_clipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def init_gtk_clipboard():
import gtk
def copy_gtk(text):
global cb
cb = gtk.Clipboard()
cb.set_text(text)
cb.store()
def paste_gtk():
clipboardContents = gtk.Clipboard().wait_for_text()
# for python 2, returns None if the clipboard is blank.
if clipboardContents is None:
return ''
else:
return clipboardContents
return copy_gtk, paste_gtk
示例4: init_gi_clipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def init_gi_clipboard():
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
def copy_gi(text):
cb.set_text(text, -1)
cb.store()
def paste_gi():
clipboardContents = cb.wait_for_text()
# for python 2, returns None if the clipboard is blank.
if clipboardContents is None:
return ''
else:
return clipboardContents
return copy_gi, paste_gi
示例5: gtkGetClipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def gtkGetClipboard():
return gtk.Clipboard().wait_for_text()
示例6: gtkSetClipboard
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def gtkSetClipboard(text):
cb = gtk.Clipboard()
cb.set_text(text)
cb.store()
示例7: _pasteGtk
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def _pasteGtk():
return gtk.Clipboard().wait_for_text()
示例8: _copyGtk
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Clipboard [as 别名]
def _copyGtk(text):
global cb
text = str(text)
cb = gtk.Clipboard()
cb.set_text(text)
cb.store()