473,388 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

tear-off buttons for Tkinter Text objects?

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
Jul 18 '05 #1
1 2112
Deacon Sweeney wrote:
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.


this approach should work:

- add custom event handlers for button press, mouse motion, and button
release.

- in the button press handler, register the current mouse coordinates
(relative to
the root window), create the toplevel, and position it in a suitable
location. also
grab the mouse pointer (to make sure you get all mouse events)
(autograbbing
may take care of that, but a little explicitness never hurts)

- in the mouse motion handler, calculate the difference between the current
mouse position and the last registered position, and move the toplevel
accordingly

- in the mouse release handler, release the grab (if necessary)

</F>


Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Kennedy | last post by:
Could anyone point me to some code/pointers that would pull down the HTML of a page as a string, a little like ASPTear?
33
by: clintonG | last post by:
Your comments or referrals to documents regarding authoring for kiosk mode configuration are wanted and appreciated. How for example must authoring be conducted to display a browser maximized...
4
by: Yves Glodt | last post by:
Hi, I need to write a heartbeat solution to monitor some external clients, and what is different as in the examples that I have seen so far is that I want my central server to poll the clients,...
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
7
by: John Salerno | last post by:
def create_sql_script(self): try: with open('labtables.sql') as sql_script: return sql_script.read() except IOError: wx.MessageBox('Could not locate the file "labtables.sql"', 'File Not Found')...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.