我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用gtk.Clipboard()。
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
def gtkGetClipboard(): return gtk.Clipboard().wait_for_text()
def gtkSetClipboard(text): cb = gtk.Clipboard() cb.set_text(text) cb.store()
def _pasteGtk(): return gtk.Clipboard().wait_for_text()
def _copyGtk(text): global cb cb = gtk.Clipboard() cb.set_text(text) cb.store()
def copy_selection(self, cut=False): (store, paths) = self.view.get_selection().get_selected_rows() maybe_cut = [] selection = [] for path in paths: iter = store.get_iter(path) mem = self._get_memory(iter) selection.append(mem.dupe()) maybe_cut.append((iter, mem)) if cut: for iter, mem in maybe_cut: mem.empty = True job = common.RadioJob(self._set_memory_cb, "erase_memory", mem.number) job.set_desc( _("Cutting memory {number}").format(number=mem.number)) self.rthread.submit(job) self._set_memory(iter, mem) result = pickle.dumps((self._features, selection)) clipboard = gtk.Clipboard(selection="CLIPBOARD") clipboard.set_text(result) clipboard.store() return cut # Only changed if we did a cut
def paste_selection(self): clipboard = gtk.Clipboard(selection="CLIPBOARD") clipboard.request_text(self._paste_selection)
def _clipboard_init(self): if not Interface._clipboard: try: from gtk import Clipboard Interface._clipboard = Clipboard() Interface._clipboard_type = 'gtk' except ImportError: try: from Tkinter import Tk Interface._clipboard = Tk() Interface._clipboard.withdraw() Interface._clipboard_type = 'tk' except ImportError: try: global StringSelection, DataFlavor, UnsupportedFlavorException, IOException, IllegalStateException from java.awt.datatransfer import StringSelection, DataFlavor from java.awt.datatransfer import UnsupportedFlavorException from java.io import IOException from java.lang import IllegalStateException from java.awt import Toolkit Interface._clipboard = Toolkit.getDefaultToolkit().getSystemClipboard() Interface._clipboard_type = 'jtk' except ImportError: try: engine.display.textbox_init() Interface._clipboard = engine.display.textarea Interface._clipboard_type = 'js' except AttributeError: Interface._clipboard = None Interface._clipboard_type = None if Interface._clipboard_type == 'gtk': self.get_clipboard = self._get_clipboard_gtk self.set_clipboard = self._set_clipboard_gtk elif Interface._clipboard_type == 'tk': self.get_clipboard = self._get_clipboard_tk self.set_clipboard = self._set_clipboard_tk elif Interface._clipboard_type == 'jtk': self.get_clipboard = self._get_clipboard_jtk self.set_clipboard = self._set_clipboard_jtk elif Interface._clipboard_type == 'js': self.get_clipboard = self._get_clipboard_js self.set_clipboard = self._set_clipboard_js