當前位置: 首頁>>代碼示例>>Python>>正文


Python Gdk.SELECTION_PRIMARY屬性代碼示例

本文整理匯總了Python中gi.repository.Gdk.SELECTION_PRIMARY屬性的典型用法代碼示例。如果您正苦於以下問題:Python Gdk.SELECTION_PRIMARY屬性的具體用法?Python Gdk.SELECTION_PRIMARY怎麽用?Python Gdk.SELECTION_PRIMARY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在gi.repository.Gdk的用法示例。


在下文中一共展示了Gdk.SELECTION_PRIMARY屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_max_input

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def test_max_input(self, mock_socket):
        """Test that the max_input limit works."""

        max_input = self.config.getint('clipster', 'max_input')
        header = "SEND:PRIMARY:0:"
        # Set the text to be the same length as max_input
        # so that total length (plus header) exceeds it.
        text = "x" * max_input
        conn = mock_socket.connect
        # Make mock conn.recv simulate bufsize 'trimming'
        conn.recv.side_effect = lambda l: (header + text)[:l]
        # Set up a fake conn fileno and client_msgs dictionary
        conn.fileno.return_value = 0
        self.daemon.client_msgs = {0: []}
        while True:
            if not self.daemon.socket_recv(conn, None):
                break
        text = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY).wait_for_text()
        # check that text length has been trimmed to max_input
        self.assertEqual(len(header) + len(text), max_input) 
開發者ID:mrichar1,項目名稱:clipster,代碼行數:22,代碼來源:tests.py

示例2: copy_name

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [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: test_read_board

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def test_read_board(self):
        """Test reading from a previously set clipboard."""
        msg = "clipster test text."
        primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        primary.set_text(msg, -1)
        self.assertEqual(msg, self.daemon.read_board('primary')) 
開發者ID:mrichar1,項目名稱:clipster,代碼行數:8,代碼來源:tests.py

示例4: test_update_board

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def test_update_board(self):
        """Test Updating the clipboard."""
        msg = "clipster test text.\n"
        self.daemon.update_board('primary', msg)
        primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        self.assertEqual(msg, primary.wait_for_text()) 
開發者ID:mrichar1,項目名稱:clipster,代碼行數:8,代碼來源:tests.py

示例5: test_clipboard

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def test_clipboard(self):
        """Copy image name to clipboard."""
        def compare_text(clipboard, text, expected_text):
            self.compare_result = False
            self.compare_result = text == expected_text
        name = self.vimiv.get_pos(True)
        basename = os.path.basename(name)
        abspath = os.path.abspath(name)
        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        # Copy basename and abspath to clipboard
        self.vimiv["clipboard"].copy_name(False)
        # Check if the info message is displayed correctly
        self.check_statusbar("INFO: Copied " + basename + " to clipboard")
        clipboard.request_text(compare_text, basename)
        self.assertTrue(self.compare_result)
        self.vimiv["clipboard"].copy_name(True)
        clipboard.request_text(compare_text, abspath)
        self.assertTrue(self.compare_result)
        # Toggle to primary and copy basename
        self.run_command("set copy_to_primary!")
        self.vimiv["clipboard"].copy_name(False)
        primary.request_text(compare_text, basename)
        self.assertTrue(self.compare_result)
        # Toggle back to clipboard and copy basename
        self.run_command("set copy_to_primary!")
        self.vimiv["clipboard"].copy_name(False)
        clipboard.request_text(compare_text, basename)
        self.assertTrue(self.compare_result) 
開發者ID:karlch,項目名稱:vimiv,代碼行數:31,代碼來源:fileactions_test.py

示例6: callback

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def callback(self, menuitems, menu, terminal):
    # retrive the context of clipboard
    self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
    self.content = self.clipboard.wait_for_text()

    # extract 5 character of the clipboard
    content_summary = self.content[0:10].strip()

    # make available search item in context menu if the clipboard isn't empty
    if len(content_summary) > 0 and content_summary != None:
      self.add_submenu(menu, ('Search For %s...' % (content_summary)), terminal) 
開發者ID:msudgh,項目名稱:terminator-search,代碼行數:13,代碼來源:terminator_search.py

示例7: __init__

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def __init__(self):
            self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
            self._selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) 
開發者ID:autokey,項目名稱:autokey,代碼行數:5,代碼來源:interface.py

示例8: __init__

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def __init__(self, app):
        self.clipBoard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        self.selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        self.app = app 
開發者ID:autokey,項目名稱:autokey,代碼行數:6,代碼來源:scripting.py

示例9: __on_copy_activate

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def __on_copy_activate(self, widget):
        """
        Provides dirty clipboard hack to get selection from inside of WebKit
        :param widget:
        """
        primary_selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        selection_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        # It does wait some short time for that text, it seems to update every now and then
        # Can get selection from anywhere in the system, no real way to tell
        selection_clipboard.set_text(primary_selection.wait_for_text(), -1) 
開發者ID:michaldaniel,項目名稱:ebook-viewer,代碼行數:12,代碼來源:main_window.py

示例10: __init__

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def __init__(self, name):
		'''Constructor
		@param name: clipboard name, can be either "CLIPBOARD" or "PRIMARY",
		see C{Gtk.Clipboard} for details.
		'''
		assert name in ('CLIPBOARD', 'PRIMARY')
		atom = Gdk.SELECTION_CLIPBOARD if name == 'CLIPBOARD' else Gdk.SELECTION_PRIMARY
		self.clipboard = Gtk.Clipboard.get(atom)
		self.data = None 
開發者ID:zim-desktop-wiki,項目名稱:zim-desktop-wiki,代碼行數:11,代碼來源:clipboard.py

示例11: get_clipboard_contents

# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 別名]
def get_clipboard_contents(targetname):
	'''Convenience function to get data from clipboard'''
	myclipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
	atom = Gdk.Atom.intern(targetname, False)
	selection = myclipboard.wait_for_contents(atom)
	assert selection is not None
	return selection.data 
開發者ID:zim-desktop-wiki,項目名稱:zim-desktop-wiki,代碼行數:9,代碼來源:clipboard.py


注:本文中的gi.repository.Gdk.SELECTION_PRIMARY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。