Python Tk Bwidget Tree problem with drag and drop

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Python Tk Bwidget Tree problem with drag and drop

Olivier Feys
Hello,

I'm working at a Tk Python gui with a Bwidget tree.

Here is the code for the creation of the tree :

self.tree = bw.Tree(self,
                            bg='lightblue3',
                            opencmd=self.open_folder,
                            closecmd=self.close_folder,
                            selectbackground='indianred3',
                            selectforeground='white',
                            deltax=10,
                            deltay=23,
                            dropenabled=1,
                            dragenabled=1,
                            dropovermode='n',
                            crossfill='red4',
                            dropcmd=self.drop,
                            dragendcmd=self.drag,
                            *args, **kw)

the problem is that when i use the dropcmd, self.drop is called with  the target node as argument with other stuff, but nothing is passed about the source node. And when I use the dragendcmd, source and target "pathnames" are passed, but I can't do anything with it. When I print these pathnames I get :

.11072656.11073776


Can anyone help me out  ?

Thanks

Olivier




_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Fwd: Python Tk Bwidget Tree problem with drag and drop

midtoad


---------- Forwarded message ----------
From: Stewart Midwinter <[hidden email]>
Date: Oct 5, 2005 8:25 AM
Subject: Re: [Tkinter-discuss] Python Tk Bwidget Tree problem with drag and drop
To: Olivier Feys <[hidden email]>

Olivier, I haven't used that widget, so this may be of little help, but it looks like you are referering an object name rather than one of its attributes.

On 10/5/05, Olivier Feys <[hidden email]> wrote:
the problem is that when i use the dropcmd, self.drop is called with  the target node as argument with other stuff, but nothing is passed about the source node. And when I use the dragendcmd, source and target "pathnames" are passed, but I can't do anything with it. When I print these pathnames I get :

.11072656.11073776


S
--
Stewart Midwinter
[hidden email]
[hidden email]
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1



--
Stewart Midwinter
[hidden email]
[hidden email]
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1


_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Python Tk Bwidget Tree problem with drag and drop

Bugzilla from jepler@unpythonic.net
In reply to this post by Olivier Feys
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 = nametowidget(src)
    dest = nametowidget(dest)
    src.insert(END, text=dest.itemcget(data, "text"))

def do_drag(src, dest, op, kind, data, result):
    if result:
        src = nametowidget(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

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

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Python Tk Bwidget Tree problem with drag and drop

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



On 05/10/05, [hidden email] <[hidden email]> 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 = nametowidget(src)
    dest = nametowidget(dest)
    src.insert(END, text=dest.itemcget(data, "text"))

def do_drag(src, dest, op, kind, data, result):
    if result:
        src = nametowidget(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:[hidden email]
Mobile phone : +32486/41.65.81

                                                    


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