[pygtk] Tutorial Clipboard.py
John Finlay
finlay at moeraki.com
Wed Jul 19 05:36:37 WST 2006
mc collilieux wrote:
> Hello, I try to run the example program of clipboard but it does not
> work with me :-(
> I have python 2.4 and pygtk 2.6.1
>
> first entry is noted in clipboard but it break at the second with :
>
> Traceback (most recent call last):
> File "clipboard.py", line 37, in clipboard_targets_received
> self.update_buttons()
> File "clipboard.py", line 16, in update_buttons
> button = self.buttons[i]
> IndexError: list index out of range
>
>
> Perhaps, i don't understand how use it ?
It's broken. Specifically the clipboard_text_received() method is
broken. Try the attached instead.
def clipboard_text_received(self, clipboard, text, data):
if not text or text == '':
return
cbi = ClipboardInfo()
cbi.text = text
# prepend and remove duplicate
self.clipboard_history = ([cbi]
+ [info for info in self.clipboard_history
if info and info.text<>text])[:10]
self.clipboard.request_targets(self.clipboard_targets_received, cbi)
return
John
More information about the pygtk
mailing list