473,405 Members | 2,445 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,405 software developers and data experts.

Push to Make (Single Pole) Button running a loop

Happy holidays all!

I'm developing an application and, as a relative newbie to Python, have come
across a stumbling block with Tkinter.

I'd like to have a button that when pressed executes a loop (this could be a
thread) and then stops execution when it's released (Push to Make - Single
Pole in electronics terms).

I've tried the regular way of associating the procedure with a callback and
tried using <Button-1and <ButtonRelease-1bindings but am getting nowhere
fast (in the latter case the button release event seems to occur anyhows).

So my question is: Is there a neat way of doing this? And would it
necessarily involve creating a custom widget?

....

Also, while I'm here, what's the state of play regarding non-ASCII in
Tkinter widgets. I've been trying to get our currency symbol, £, to display
but didn't have much luck even playing with the coding: settings.

TIA

jon
Dec 30 '07 #1
1 1526
"Jon Todd" <jo...en.co.ukwrote:
>I'd like to have a button that when pressed executes a loop (this could be a
thread) and then stops execution when it's released (Push to Make - Single
Pole in electronics terms).

I've tried the regular way of associating the procedure with a callback and
tried using <Button-1and <ButtonRelease-1bindings but am getting nowhere
fast (in the latter case the button release event seems to occur anyhows).
You are a bit stymied :

Afaik, Button needs the click on the button, leaving it depressed,
while ButtonRelease needs a click on the button, and the release can be anywhere
for drag and drop implementation. So it is possible to call two routines with
one
click and release.

But there is another hassle - you would have to code the loop as a separate
thread,
started by the first, while the second routine sets some variable that is
checked by
the loop to kill itself, as the GUI will not be responsive until the first
command
returns, because the command "captures" the main loop...

HTH - Hendrik
Dec 31 '07 #2

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

Similar topics

6
by: Will | last post by:
Hi, Sorry to be a pest... But I can figure this out. I'm pushing to a stack. then I need to check to see if the word is a palindrome. Is the code below correct? if so, how can I check the...
1
by: kaiser | last post by:
Hello. I am trying to write a program that continues to read the last line of a txt file until a stop button is clicked. while (ContinueLoop == true ) { while ((LastLine = file.ReadLine()) !=...
1
by: Mirco | last post by:
I must make a aspx page that make these single steps: 1. when I open it is green 2. when I click a button it is blue 3. when I click the same button it is red alternate 2 and 3 I have...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
20
by: merrittr | last post by:
I need some C advice I want to read in string commands from a user when the user enters a \n I want to push it on the stac. Then at some point , if the user enters the word print pop off and print...
4
by: Marcpp | last post by:
Hi I need to call a widget from a button in WXPYTHON. I've tried to this from a function like this, but when push the button, the program opens a window and do error. Any idea? ...... def...
1
by: Siegfried Heintze | last post by:
The following code below is single threaded. When I click the start button, it hogs the message pump so none of the UI works. How can I convert this to make it multi-threaded so I can continue to...
15
by: Alex Snast | last post by:
Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i >= 0; --i)
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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,...

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.