On Tue, Nov 16, 1999 at 04:55:25PM +0100, Jozsa Kristof wrote:
>
> Is it possible to use drag'n'drop from and to a CList? I tried in a similar
> way then in pygtk/examples/simple/dnd.py but failed miserably. Even if I set
> the selection mode to SELECTION_SINGLE, if I try to drag from the list, the
> list only changes its active row.. nothing else. Same when I try to drop to
> the list from elsewhere. Any ideas? Or is it inpossible?
Here is the simple example for using dnd in clist.
Hope this will help you.
#! /usr/bin/env python
target = [
('STRING', 0, 0),
('text/plain', 0, 0),
('text/html', 0, 1)]
from GDK import *
from gtk import *
def dnd_received_cb(w, context, x, y, data, info, time):
if data and data.format == 8:
w.drag_finish(context, 1, 0, time)
if y > clist_title_height:
row, col = w.get_selection_info(x,y-clist_title_height)
print 'destination: row=%d col=%d' % (row, col)
else:
print 'destination: title bar'
print 'received string is "%s"' % data.data
else:
w.drag_finish(context, 0, 0, time)
def source_get(w, context, selection_data, info, time):
data = "I am from %s row" % `w.selection`
selection_data.set(selection_data.target, 8, data)
def source_del(w, context, data):
pass
win = GtkWindow()
clist = GtkCList(2, ["Title1", "Title2"])
clist.append(["content1", "content2"])
clist.append(["content3", "content4"])
clist.drag_dest_set(DEST_DEFAULT_ALL, target, ACTION_COPY|ACTION_MOVE)
clist.connect('drag_data_received', dnd_received_cb)
clist.drag_source_set(BUTTON1_MASK|BUTTON3_MASK, target, ACTION_COPY|ACTION_MOVE)
clist.connect('drag_data_get', source_get)
clist.connect('drag_data_delete', source_del)
clist_title_height = 1
while 1:
if clist.get_selection_info(0, clist_title_height)[0] == 1: break
clist_title_height = clist_title_height + 1
win.add(clist)
win.show_all()
mainloop()
>
> Yeah and something else: is it normal or acceptable to get messages like
> this at a pygtk program startup? Can I do anything in my code to fix it? (my
> stuff seem to work ok, it just dump this)
> -
> Gtk-CRITICAL **: file gtkwidget.c: line 1584 (gtk_widget_map): assertion
> TK_WIDGET_VISIBLE (widget) == TRUE' failed.
>
> Gtk-CRITICAL **: file gtkwidget.c: line 1584 (gtk_widget_map): assertion
> TK_WIDGET_VISIBLE (widget) == TRUE' failed.
> -
>
> Christopher
> --
> +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-: .~. :-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
> | Christopher Jozsa /V\ Veszprem Linux Users Group |
> | [EMAIL PROTECTED] /( )\ student of IT, Hungary |
> +-=-=-=-=-=-=-=-=-=-=-=-=-=-=--: ^^-^^ :--=-=-=-=-=-=-=-=-=-=-=-=-=-+
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]