当前位置: 首页>>代码示例>>Python>>正文


Python Gdk.SELECTION_CLIPBOARD属性代码示例

本文整理汇总了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. 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:25,代码来源:taskview.py

示例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") 
开发者ID:karlch,项目名称:vimiv,代码行数:25,代码来源:fileactions.py

示例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 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:21,代码来源:Pyperclip.py

示例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() 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:6,代码来源:clipboard.py

示例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) 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:11,代码来源:clipboard.py

示例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) 
开发者ID:chr314,项目名称:nautilus-copy-path,代码行数:4,代码来源:nautilus_copy_path.py

示例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) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:29,代码来源:gui_utilities.py

示例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 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:11,代码来源:backend_gtk3.py

示例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 
开发者ID:gramps-project,项目名称:addons-source,代码行数:14,代码来源:QuiltView.py

示例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 
开发者ID:gramps-project,项目名称:addons-source,代码行数:14,代码来源:HtreePedigreeView.py

示例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 
开发者ID:gramps-project,项目名称:addons-source,代码行数:14,代码来源:HtreePedigreeView.py

示例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 
开发者ID:gramps-project,项目名称:addons-source,代码行数:16,代码来源:graphview.py

示例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 
开发者ID:gramps-project,项目名称:addons-source,代码行数:13,代码来源:TimelinePedigreeView.py

示例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 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:32,代码来源:taskview.py

示例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() 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:6,代码来源:taskview.py


注:本文中的gi.repository.Gdk.SELECTION_CLIPBOARD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。