I am struggling to fire suitable events when dragging a row from a treeview
onto an eventbox. The code at http://phpfi.com/179070 and below doesn't run
the sig_dropped or drag_data_get functions. What am I missing?

Cheers,

Stephen English

import pygtk, gtk, gobject

def sig_dropped(widget, drag_context, x, y, selection, targettype, timestamp):
   print widget
   print drag_context
   print x
   print y
   print timestamp

def drag_data_get(widget, drag_context, selection_data, info, time):
   print widget, drag_context, selection_data, info, time, data
   selection_data.set(selection_data.target, 8, "moo")

image = gtk.Image()
image.set_from_file("schem.png")
image.show()
evbox = gtk.EventBox()
evbox.add(image)
evbox.connect("drag-data-received", sig_dropped)
evbox.drag_dest_set(gtk.DEST_DEFAULT_DROP, [('text/plain',
   gtk.TARGET_SAME_APP, 0)], gtk.gdk.ACTION_COPY)
evbox.show()

model = gtk.TreeStore(gobject.TYPE_STRING)
iter = model.insert_before(None, None)
model.set_value(iter, 0, "Test1")
iter = model.insert_before(None, None)
model.set_value(iter, 0, "Test2")
iter = model.insert_before(None, None)
model.set_value(iter, 0, "Test3")

tv = gtk.TreeView(model)
renderer = gtk.CellRendererText()
col = gtk.TreeViewColumn("Test", renderer, text=0)
tv.append_column(col)

tv.connect("drag-data-get", drag_data_get)
tv.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('text/plain',
       gtk.TARGET_SAME_APP, 0),], gtk.gdk.ACTION_COPY)

tv.set_property("width-request", 200)
tv.show()

hbox = gtk.HBox(False, 10)
hbox.pack_start(evbox, expand=True, fill=True, padding=0)
hbox.pack_start(tv, expand=False, fill=False, padding=0)
hbox.show()
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
win.connect("delete-event", lambda w, x: gtk.main_quit())
win.add(hbox)
win.show()
gtk.main()
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to