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()
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))
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
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)
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)
#!/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)
def copy_gtk(text): global cb text = _stringifyText(text) # Converts non-str values to str. cb = Clipboard() cb.set_text(text) cb.store()