tear-off buttons for Tkinter Text objects?

Deacon Sweeney sweeney.2 at wright.edu
Mon Apr 5 23:20:55 EDT 2004


Hi. I've embedded some buttons in a Text object, and I would like these
buttons to perform a 'tear-off' of that line when clicked. That is, when the
button is clicked, I would like a new Toplevel to appear with a new Text
object which contains the text. Creating a 'pop-off' button, where the
Toplevel appears at some predetermined (or calculatable) point would be
easy, I'd just create the Toplevel, position it, and pass the info to it.
The difference would be that the 'tear-off' button would automatically
'grab' the new Toplevel so that it could be easily repositioned in the same
motion of the mouse.

There are three benefits to this that make it worthwhile. One, obviously
repositioning is one mouse click easier. Two, I'll also add code to dock the
lines, so re-docking a mistaken tear-off would be easier as well. Three, its
just cool.

So is there maybe some way to trick the window manager into thinking there's
been a mouse click? It would be easy enough to position the title bar of the
new Toplevel under the cursor. Or can the new window just be (magically)
bound to the cursor until the button-pressing click is released? Any help
would be appreciated.

Thanks,

Deacon Sweeney





More information about the Python-list mailing list