Thanks a lot Jeff, i think this is really going to help me.



On 05/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I haven't used bwidget drag and drop myself.

You can get the widget object for a string path by using bwidget.nametowidget
but I had trouble with this since often the name of an internal widget, such as
(in my case) '.1077785676.c', is returned.  Perhaps by chopping off parts until
a recognized widget is found will work.

Here's a small program I just wrote which demonstrates drag&drop between two
ListBox (not Tree) widgets.

from Tkinter import *
from bwidget import *
import bwidget

def nametowidget(name):
    while name:
        try:
            return bwidget.nametowidget(app, name)
        except KeyError:
            i = name.rindex('.')
            name = name[:i]

def draginit(a, b, c): return ('LISTBOX_ITEM', 'move', b)

def do_drop(src, dest, where, op, kind, data):
    src = "">    dest = nametowidget(dest)
    src.insert(END, text=dest.itemcget(data, "text"))

def do_drag(src, dest, op, kind, data, result):
    if result:
        src = "">        src.delete(data)

common_args = {'dropcmd': do_drop, 'dragendcmd': do_drag, 'dragenabled': 1,
    'dropenabled': 1, 'dropovermode': 'w'}

app = Tk()

t = ListBox(app, **common_args)
t.pack(side=LEFT)
for text in "abcde":
    t.insert(END, text=text*3)

u = ListBox(app, **common_args)
u.pack(side=LEFT)
for text in "12345":
    u.insert(END, text=text*3)

app.mainloop()


Jeff





--
                                                    
Olivier Feys                                      

Ringlaan 20
B-3080 Tervuren - BELGIUM
mailto:[EMAIL PROTECTED]
Mobile phone : +32486/41.65.81

                                                    

_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to