http www google ru search complete hl ru python get x11 clipboard прив

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
http://www.google.ru/search?complete=1&hl=ru&q=python+get+x11+clipboard
приводит на
http://www.vector-seven.com/category/languages/python/
там ищем по странице по слову Clipboard, открываем питон, и пишем
"""
import pygtk
>>> pygtk.require('2.0')
>>> import gtk
>>>
>>> clipboard = gtk.clipboard_get()
>>>
>>> help(clipboard)
>>> clipboard.request_text()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: GtkClipboard.request_text() takes at least 1 argument (0 given)
>>> help(clipboard)
>>> clipboard.request_text(1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: callback must be callable
>>> clipboard.request_text(lambda x: print x)
File "<stdin>", line 1
clipboard.request_text(lambda x: print x)
^
SyntaxError: invalid syntax
>>> def cb(text):
... print text
...
>>> clipboard.request_text(cb)
>>> help(gtk)
/usr/lib/python2.4/pydoc.py:969: GtkDeprecationWarning: gtk.FALSE is deprecated, use False instead
return cram(stripid(repr(x)), self.maxstring)
/usr/lib/python2.4/pydoc.py:969: GtkDeprecationWarning: gtk.TRUE is deprecated, use True instead
return cram(stripid(repr(x)), self.maxstring)
>>> gtk.mainloop()
__main__:1: GtkDeprecationWarning: gtk.mainloop is deprecated, use gtk.main instead
TypeError: cb() takes exactly 1 argument (3 given)
^CTraceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/deprecation.py", line 62, in __call__
return func(*args, **kwargs)
KeyboardInterrupt
"""
Открываем file:///usr/share/gtk-doc/html/gtk/gtk-Clipboards.html
там ищем по ключевому слову request_text
дальше по ссылке смотрим на GtkClipboardTextReceivedFunc
"""
>>> def cb(foo, bar, baz):
... print foo, bar, baz
...
>>> clipboard.request_text(cb)
>>> gtk.main()
<gtk.Clipboard object at 0xb7c896e4 (GtkClipboard at 0x816fa98)> right None
^CTraceback (most recent call last):
File "<stdin>", line 1, in ?
KeyboardInterrupt