[pygtk] gtk.Clipboard and custom selection targets under win32

Richard Procter rnp at paradise.net.nz
Tue Oct 2 08:13:18 WST 2007


Hi all,

I'm trying to share application-specific data between my program  
instances using the gtk.Clipboard and a custom target to distinguish  
it from normal text.

The following snippets work on linux but not on win32, where it gives  
the warning:
copy:13: GtkWarning: gdk_property_change: assertion `type !=  
GDK_TARGET_STRING' failed
This appears to come from gdk/win32/gdkproperty-win32.c

Has anyone used custom selection targets under win32 with more success?

regards,
Richard.

The 'copy' process
"""
import pygtk
pygtk.require('2.0')
import gtk

def get_f(clipboard, selection, target_handle, userdata):
     selection.set("STRING", 8, "Hello there")

def clear_f(clipboard, userdata):
     pass

targets = [("Foobar", 0, 0)]
gtk.clipboard_get().set_with_data(targets, get_f, clear_f)
gtk.main()
"""

The 'paste' process
"""
import pygtk
pygtk.require('2.0')
import gtk

def request_f(clipboard, selection, userdata):
     print "Target ", selection.target
     print "Type ", selection.type
     print "Format ", selection.format
     print "Data in selection is ", selection.data

gtk.clipboard_get().request_contents("Foobar", request_f)
gtk.main()
"""

Under linux, the string in the custom target is copied successfully:
"""
Target  Foobar
Type  STRING
Format  8
Data in selection is  Hello there
"""

Under win32, I get
copy:13: GtkWarning: gdk_property_change: assertion `type !=  
GDK_TARGET_STRING' failed

win32 (Windows 2000 SP4):
gtk.pygtk_version == (2, 8, 6) or (2, 10, 6)
gtk.gtk_version == (2, 8, 10)  or (2, 10, 11)
python 2.4

linux:
gtk.pygtk_version == (2, 8, 6)
gtk.gtk_version == (2, 8, 20)
python 2.4



More information about the pygtk mailing list