Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:29:42+00:00 2026-05-16T17:29:42+00:00

The following python line will bind the method click to the event when the

  • 0

The following python line will bind the method “click” to the event when the user presses the mouse button while the pointer is on the widget; no matter where the pointer is when she releases the button.

self.bind('<Button-1>',self.click)

If I use “ButtonRelease” instead of “Button” in the code, it seems that the method “click” will be called for the widget on which the mouse was pressed after the button release; no matter where you release it.

1- Isn’t there a neat way to make it call the bound method only if the mouse button was released on my widget; no matter where it was pressed?

2- Isn’t there neat way to tell it to react only in case of a full click (press and release both on the same widget)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:29:43+00:00Added an answer on May 16, 2026 at 5:29 pm

    1- Isn’t there a neat way to make it
    call the bound method only if the
    mouse button was released on my
    widget; no matter where it was
    pressed?

    2- Isn’t there neat way to tell it to
    react only in case of a full click
    (press and release both on the same
    widget)?

    No “neat” way, because, as Tkinter’s docs say:

    When you press down a mouse button
    over a widget, Tkinter will
    automatically “grab” the mouse
    pointer, and mouse events will then be
    sent to the current widget as long as
    the mouse button is held down.

    and both of your desires are incompatible with this automatic grabbing of the mouse pointer on press-down (which I don’t know how to disable — I think it may be impossible to disable, but proving a negative is hard;-).

    So, you need more work, and a non-“neat” solution: on the button-down event’s callback, bind the enter and leave events (to bound methods of a class instance where you can track whether the mouse is currently inside or inside the widget of interest) of that window as well as the button-release; this way, when the release event comes, you know whether to perform the “actual application callback” (if inside) or do nothing (if outside) — that gives you your desire number 2, but describing this as neat would be a stretch.

    Desire number 1 is even harder, because you have to track enter and leave events on EVERY widget of interest — it’s not enough to know one bit, whether the mouse is inside or outside, but rather you must keep track of which widget (if any) it’s currently in, to direct the “actual application callback” properly (if at all) at button release time.

    While the internals aren’t going to be neat, each functionality can be bound into one neat-to-call function… with slightly “indaginous” internals (a term that’s used more often to refer to root canal work or the like, rather than programming, but may be appropriate when you’re wanting to go against the grain of functionality hard-coded in a framework… that’s the downside of frameworks — you’re in clover as long as you want to behave in ways they support, but when you want to defeat their usual behaviors to do something completely different, that can hardly ever be “neat”!-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My python IDE PyCharm by defaults suggests to change the following line of python:
the following is a line from a python program that calls the demo.exe file.
The following python script prints the first occurrence of a line in a file.
So I'm running the following code from the command line python: import logging rootLog
Observe the following Python script, Script.py: import subprocess src_directory = 'Z:\z_7z\Some_Directory' zip_file_name = 'Test.7z'
I have the following python script which takes some inputs and puts them in
I tried running the following python code in Eclipse on Windows but it is
When running the following python code: >>> f = open(rmyfile.txt, a+) >>> f.seek(-1,2) >>>
I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where
I have the following Python 2.6 program and YAML definition (using PyYAML ): import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.