473,796 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2130
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
3419
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
3494
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 with no chrome? Is it even possible with ANY of the browsers? <%= Clinton Gallagher
4
1679
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, and not the clients "pinging" the central server. In detail I need a daemon on my central server which e.g. which in a loop pings (not really ping but you know what I mean) each 20 seconds one of the clients.
23
7818
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 called, can be a genuine no-op. Consider: typedef int(*polymorphic_func)(int param);
7
1113
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') OR
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.