Python gtk.Clipboard() Examples

The following are 24 code examples of gtk.Clipboard(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gtk , or try the search function .
Example #1
Source File: __init__.py    From gist-alfred with MIT License 6 votes vote down vote up
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(): 
Example #2
Source File: clipboards.py    From ci_edit with Apache License 2.0 6 votes vote down vote up
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 
Example #3
Source File: Pyperclip.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 6 votes vote down vote up
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(): 
Example #4
Source File: Pyperclip.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #5
Source File: Pyperclip.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #6
Source File: clipboards.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #7
Source File: clipboards.py    From Splunking-Crime with GNU Affero General Public License v3.0 6 votes vote down vote up
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 
Example #8
Source File: Pyperclip.py    From MIA-Japanese-Add-on with GNU General Public License v3.0 6 votes vote down vote up
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(): 
Example #9
Source File: Pyperclip.py    From MIA-Japanese-Add-on with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #10
Source File: clip.py    From pappy-proxy with MIT License 6 votes vote down vote up
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 
Example #11
Source File: clipboards.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
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 
Example #12
Source File: clipboards.py    From vnpy_crypto with MIT License 6 votes vote down vote up
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 
Example #13
Source File: clipboards.py    From recruit with Apache License 2.0 6 votes vote down vote up
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 
Example #14
Source File: __init__.py    From gist-alfred with MIT License 6 votes vote down vote up
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 
Example #15
Source File: pyperclip.py    From GDMC with ISC License 5 votes vote down vote up
def _copyGtk(text):
    global cb
    text = str(text)
    cb = gtk.Clipboard()
    cb.set_text(text)
    cb.store() 
Example #16
Source File: pyperclip.py    From GDMC with ISC License 5 votes vote down vote up
def _pasteGtk():
    return gtk.Clipboard().wait_for_text() 
Example #17
Source File: pyperclip.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def gtkSetClipboard(text):
    cb = gtk.Clipboard()
    cb.set_text(text)
    cb.store() 
Example #18
Source File: pyperclip.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def _pasteGtk():
    return gtk.Clipboard().wait_for_text() 
Example #19
Source File: pyperclip.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def _copyGtk(text):
    global cb
    text = str(text)
    cb = gtk.Clipboard()
    cb.set_text(text)
    cb.store() 
Example #20
Source File: pyperclip.py    From deskcon-desktop with GNU General Public License v3.0 5 votes vote down vote up
def gtkGetClipboard():
    return gtk.Clipboard().wait_for_text() 
Example #21
Source File: clipboard.py    From Computable with MIT License 5 votes vote down vote up
def gtkSetClipboard(text):
    cb = gtk.Clipboard()
    cb.set_text(text)
    cb.store() 
Example #22
Source File: clipboard.py    From Computable with MIT License 5 votes vote down vote up
def gtkGetClipboard():
    return gtk.Clipboard().wait_for_text() 
Example #23
Source File: pyperclip.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def _pasteGtk():
    return gtk.Clipboard().wait_for_text() 
Example #24
Source File: pyperclip.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def _copyGtk(text):
    global cb
    text = str(text)
    cb = gtk.Clipboard()
    cb.set_text(text)
    cb.store()