예제 #1
0
 def get(self):
     """Retrieves the clipboard's current value."""
     if self.__USE == 'gtk':
         from gtk import Clipboard
         clip = Clipboard()
         return clip.wait_for_text()
     elif self.__USE == 'win32':
         pass
     elif self.__USE == 'pbpaste':
         import os
         return os.popen('pbpaste', 'wb').read
     else:
         import os
         if self.__USE == 'xsel': flag = 'b'
         else: flag = ''
         return os.popen('%s -%so' % (self.__USE, flag)).read()
예제 #2
0
def myblock(tw, x):  # second argument is ignored
    ''' Copy heap to clipboard '''

    from gtk import Clipboard
    from TurtleArt.tautils import data_to_string

    Clipboard().set_text(data_to_string(tw.lc.heap))
예제 #3
0
 def paste_gtk():
     clipboardContents = Clipboard().wait_for_text()
     # for python 2, returns None if the clipboard is blank.
     if clipboardContents is None:
         return ''
     else:
         return clipboardContents
예제 #4
0
 def set(self, text):
     """Sets the value of the clipboard to the supplied text."""
     if self.__USE == 'gtk':
         from gtk import Clipboard
         clip = Clipboard()
         clip.set_text(text)
         clip.store()
     elif self.__USE == 'win32':
         pass
     elif self.__USE == 'pbpaste': # OS X needs pbcopy to write
         import os
         os.popen('pbcopy', 'wb').write(text)
     else:
         import os
         if self.__USE == 'xsel': flag = 'b'
         else: flag = ''
         os.popen('%s -%si' % (self.__USE, flag), 'wb').write(text)
예제 #5
0
def myblock(tw, x):  # ignore second argument
    ''' Paste from clipboard to heap '''

    from gtk import Clipboard
    from tautils import data_from_string

    text = Clipboard().wait_for_text()
    if text is not None:
        for val in data_from_string(text):
            tw.lc.heap.append(val)
        tw.lc.update_label_value('pop', val)
예제 #6
0
#!/usr/bin/env python

from sys import exit
from time import time
from gtk import Clipboard

stardate_raw = str(time())
stardate = stardate_raw[1:6] + "," + stardate_raw[6]

print(stardate)

cb = Clipboard()
cb.set_text(stardate)
cb.store()

exit(0)
예제 #7
0
 def copy_gtk(text):
     global cb
     text = _stringifyText(text)  # Converts non-str values to str.
     cb = Clipboard()
     cb.set_text(text)
     cb.store()