本文整理匯總了Python中gi.repository.Gdk.SELECTION_CLIPBOARD屬性的典型用法代碼示例。如果您正苦於以下問題:Python Gdk.SELECTION_CLIPBOARD屬性的具體用法?Python Gdk.SELECTION_CLIPBOARD怎麽用?Python Gdk.SELECTION_CLIPBOARD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類gi.repository.Gdk
的用法示例。
在下文中一共展示了Gdk.SELECTION_CLIPBOARD屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: copy_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def copy_clipboard(self, widget, param=None):
clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# First, we analyse the selection to put in our own
# GTG clipboard a selection with description of subtasks
bounds = self.buff.get_selection_bounds()
if not bounds:
return
start, stop = self.buff.get_selection_bounds()
self.clipboard.copy(start, stop, bullet=self.bullet1)
text = self.clipboard.paste_text()
clip.set_text(text, len(text))
clip.store()
if param == "cut":
self.buff.delete_selection(False, True)
self.stop_emission("cut_clipboard")
else:
self.stop_emission("copy_clipboard")
# Called on paste.
示例2: copy_name
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def copy_name(self, abspath=False):
"""Copy image name to clipboard.
Args:
abspath: Use absolute path or only the basename.
"""
# Get name to copy
name = self._app.get_pos(True)
if abspath:
name = os.path.abspath(name)
else:
name = os.path.basename(name)
# Set clipboard
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) \
if settings["copy_to_primary"].get_value() \
else Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# Text to clipboard
clipboard.set_text(name, -1)
# Info message
message = "Copied <b>" + name + "</b> to %s" % \
("primary" if settings["copy_to_primary"].get_value()
else "clipboard")
self._app["statusbar"].message(message, "info")
示例3: init_gi_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_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
示例4: clear
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def clear():
"""Clear the clipboard."""
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.clear()
示例5: set
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def set(string):
"""
Copy a string to the clipboard.
:param string: the string to copy.
:type string: str
"""
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(string, -1)
示例6: __init__
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def __init__(self):
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
示例7: gtk_treeview_selection_to_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def gtk_treeview_selection_to_clipboard(treeview, columns=0):
"""
Copy the currently selected values from the specified columns in the
treeview to the users clipboard. If no value is selected in the treeview,
then the clipboard is left unmodified. If multiple values are selected, they
will all be placed in the clipboard on separate lines.
:param treeview: The treeview instance to get the selection from.
:type treeview: :py:class:`Gtk.TreeView`
:param column: The column numbers to retrieve the value for.
:type column: int, list, tuple
"""
treeview_selection = treeview.get_selection()
(model, tree_paths) = treeview_selection.get_selected_rows()
if not tree_paths:
return
if isinstance(columns, int):
columns = (columns,)
tree_iters = map(model.get_iter, tree_paths)
selection_lines = []
for ti in tree_iters:
values = (model.get_value(ti, column) for column in columns)
values = (('' if value is None else str(value)) for value in values)
selection_lines.append(' '.join(values).strip())
selection_lines = os.linesep.join(selection_lines)
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(selection_lines, -1)
示例8: trigger
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def trigger(self, *args, **kwargs):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
window = self.canvas.get_window()
x, y, width, height = window.get_geometry()
pb = Gdk.pixbuf_get_from_window(window, x, y, width, height)
clipboard.set_image(pb)
# Define the file to use as the GTk icon
示例9: copy_person_to_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def copy_person_to_clipboard(self, obj, person_handle):
"""
Renders the person data into some lines of text
and puts that into the clipboard.
"""
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
cb = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
Gdk.SELECTION_CLIPBOARD)
cb.set_text(self.format_helper.format_person(person, 11), -1)
return True
return False
示例10: cb_copy_person_to_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def cb_copy_person_to_clipboard(self, obj, person_handle):
"""
Renders the person data into some lines of text and
puts that into the clipboard
"""
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(self.format_helper.format_person(person, 11), -1)
return True
return False
示例11: cb_copy_family_to_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def cb_copy_family_to_clipboard(self, obj, family_handle):
"""
Renders the family data into some lines of text and
puts that into the clipboard
"""
family = self.dbstate.db.get_family_from_handle(family_handle)
if family:
clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(self.format_helper.format_relation(family, 11), -1)
return True
return False
示例12: copy_person_to_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def copy_person_to_clipboard(self, obj):
"""
Renders the person data into some lines of text
and puts that into the clipboard.
"""
person_handle = obj.get_data()
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
_cb = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
Gdk.SELECTION_CLIPBOARD)
format_helper = FormattingHelper(self.dbstate)
_cb.set_text(format_helper.format_person(person, 11), -1)
return True
return False
示例13: copy_person_to_clipboard_cb
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def copy_person_to_clipboard_cb(self, obj, person_handle):
"""
Renders the person data into some lines of text and
puts that into the clipboard
"""
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(self.format_helper.format_person(person, 11), -1)
return True
return False
示例14: paste_clipboard
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def paste_clipboard(self, widget, param=None):
clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# if the clipboard text is the same are our own internal
# clipboard text, it means that we can paste from our own clipboard
# else, that we can empty it.
our_paste = self.clipboard.paste_text()
if our_paste is not None and clip.wait_for_text() == our_paste:
# first, we delete the current selection
self.buff.delete_selection(False, True)
for line in self.clipboard.paste():
if line[0] == 'text':
self.buff.insert_at_cursor(line[1])
if line[0] == 'subtask':
tid = line[1]
self.new_subtask_callback(tid=tid)
mark = self.buff.get_insert()
line_nbr = self.buff.get_iter_at_mark(mark).get_line()
# we must paste the \n before inserting the subtask
# else, we will start another subtask
self.buff.insert_at_cursor("\n")
self.write_subtask(self.buff, line_nbr, tid)
# we handle ourselves the pasting
self.stop_emission("paste_clipboard")
else:
# we keep the normal pasting by not interupting the signal
self.clipboard.clear()
# Function called each time the user inputs a letter
示例15: __copy_link
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_CLIPBOARD [as 別名]
def __copy_link(self, menu_item, anchor):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(anchor, -1)
clipboard.store()