> Christian Reis wrote:
>Hmmm. Right. Now what do I do with it? IOW, how do I actually manipulate
>the cut/copy/paste into/from it?
>
The gtk tutorial (1.2) as a section describing how to deal with selections.
You may also check pygtk example 'dnd.py' or the following sample code.
Regards,
Pedro
# ----------------------------------------------------------------------
import gtk
import GDK
# ----------------------------------------------------------------------
# XXX
GDK.CURRENT_TIME = 0
GDK.SELECTION_PRIMARY = gtk.atom_intern("PRIMARY")
# /XXX
# ----------------------------------------------------------------------
def quit(*args):
gtk.mainquit()
# ----------------------------------------------------------------------
def paste_cliced(*args):
# Asynchonous query
w.selection_convert(GDK.SELECTION_PRIMARY
, GDK.SELECTION_TYPE_STRING
, GDK.CURRENT_TIME
)
def clipboard_data_received(wdgt, data, time, *args):
global clip_data
if data is not None:
clip_data = data.data
# print dir(data)
print "clipboard contains '%s'" % clip_data
# ----------------------------------------------------------------------
def copy_clicked(wdgt, *args):
if wdgt.selection_owner_set(GDK.SELECTION_PRIMARY, GDK.CURRENT_TIME):
print "got the selection ownership"
def get_selection(wdgt, data, *args):
global clip_data
data.set(GDK.SELECTION_TYPE_STRING
, 8
, "[me %s]" % clip_data
)
print "somebody queried me"
def lost_selection(wdgt, *args):
print "lost the selection"
# ----------------------------------------------------------------------
clip_data = ""
w = gtk.GtkWindow()
v = gtk.GtkVBox()
bp = gtk.GtkButton(label="Paste")
bc = gtk.GtkButton(label="Copy")
w.add(v)
v.add(bp)
v.add(bc)
w.connect("delete_event", quit)
w.connect("destroy_event", quit)
w.connect("selection_received", clipboard_data_received)
bp.connect("clicked", paste_cliced)
bc.connect("clicked", copy_clicked)
# ----------------------------------------------------------------------
bc.selection_add_target(GDK.SELECTION_PRIMARY, GDK.SELECTION_TYPE_STRING, 1)
bc.connect("selection_get", get_selection)
bc.connect("selection_clear_event", lost_selection)
# ----------------------------------------------------------------------
w.show_all()
gtk.mainloop()
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/