Python TkinterTreectrl drag items -
i writing program in python allow me browse through experimental data have taken, , view metadata associated experimental conditions each dataset.
at heart of program tkintertreectrl
widget, wrapper tk treectrl
despite being rather novice programmer, far working - can add items, remove items, select them etc etc.
however, cannot work out how allow dragging of items new locations in tree. have found in documentation many references drag images, , @ moment can drag tantalizing dotted outline around. cannot find events generated on drag , drop. closest find in manual following set of events:
<drag-begin> <drag-receive> <drag-end>: generated whenever user drag-and-drops file directory. event generated filelist-bindings.tcl library code, not used default.
i not know how use "filelist-bindings.tcl
library code", not sure correct approach anyway.
in related query - thought 1 way solve , similar problems send every event generated treectrl
widget stdout
. there way this?
a minimal working example here rather large of use, excerpt may help:
# add callbacks edit events self.t.notify_install('<edit-begin>') self.t.notify_bind('<edit-begin>', self.edit_begin) self.t.notify_install('<edit-accept>') self.t.notify_bind('<edit-accept>', self.edit_accept) self.t.notify_install('<edit-end>') self.t.notify_bind('<edit-end>', self.edit_end) # add callbacks mouse clicks self.t.bind('<button-1>', self.onleftclick) self.t.bind('<button-3>', self.onrightclick) # add callbacks drag events self.t.notify_install('<drag-begin>') self.t.bind('<drag-begin>', self.ondrag) self.t.notify_install('<drag-recieve>') self.t.bind('<drag-recieve>', self.ondrag) self.t.notify_install('<drag-end>') self.t.bind('<drag-end>', self.ondrag)
callbacks edit events , mouse clicks work fine, attempting bind drag events generates _tkinter.tclerror: bad event type or keysym "drag"
ignoring fact question not newest 1 - there specific reason why use self.t.bind
instead of self.t.notify_bind
?
for me looks pretty point interface tktreecrtl michael not using wrapper functionality attempting directly bind <drag-begin>
treectrl
instance based on tkinter.widget
- source extract:
class treectrl(tkinter.widget):
tkinter.widget
has no possibility find '' event generated inside tktreectrl libraries.
bad event type or keysym "drag"
changing self.t.notify_bind
should solve problem.
Comments
Post a Comment