[Tkinter-discuss] Text drag&drop

Michael Lange klappnase at web.de
Sun Nov 4 16:56:25 EST 2018


Hi,

On Sun, 4 Nov 2018 19:37:29 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

(...)
> #1. However I cannot get rid of the #1. I've tried to subclass the
> #DndHandler()
> especially the on_motion() method to delete the text anchor (dirty
> hack) after looking at the text.tcl  as well deleting the selection and
> calling the CancelRepeat to avoid the auto-scrolling, but nothing
> worked ok. Is there a way to tell the Text() to stop the selection?

I think you could add something like this to DnDHandler.__init__() :

        def _return_break(widget, event):
            return 'break'
        self._id = widget.bind('<B1-Motion>')
        widget.bind('<B1-Motion>', _return_break)

which should remove the motion-selection binding and then restore it after
the dnd operation has finished by adding

        self.initial_widget.bind('<B1-Motion>', self._id)

to the end of DnDHandler.finish() (untested however).

Regards

Michael





.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

	"The combination of a number of things to make existence
worthwhile." "Yes, the philosophy of 'none,' meaning 'all.'"
		-- Spock and Lincoln, "The Savage Curtain", stardate
5906.4


More information about the Tkinter-discuss mailing list