Python Forum
How to break out of a for loop on button press?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to break out of a for loop on button press?
#5
If you want to use after() in the way the OP was going, it has to call itself.
def process():
    ## replace for with after
    ##for i in range(100):
    if some_condition:        ...
        root.after(milliseconds, process)
        # playing a midi-file here 
Or look at one of the tkinter video players like https://pypi.org/project/tkvideoplayer/ I don't use them so don't know, but this one says it has pause and stop commands.
philipbergwerf likes this post
Reply


Messages In This Thread
RE: How to break out of a for loop on button press? - by woooee - Oct-04-2022, 10:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Button to stop while loop from another script Absolutewind 5 1,007 Sep-25-2023, 11:20 PM
Last Post: deanhystad
  Code won't break While loop or go back to the input? MrKnd94 2 1,036 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  break out of for loop? User3000 3 1,511 May-17-2022, 10:18 AM
Last Post: User3000
  Asyncio: Queue consumer gets out of while loop without break. Where exactly and how? saavedra29 2 2,748 Feb-07-2022, 07:24 PM
Last Post: saavedra29
  tkinter auto press button kucingkembar 2 3,279 Dec-24-2021, 01:23 PM
Last Post: kucingkembar
  tkinter control break a while loop samtal 0 2,431 Apr-29-2021, 08:26 AM
Last Post: samtal
  Cannot 'break' from a "for" loop in a right place tester_V 9 4,066 Feb-17-2021, 01:03 AM
Last Post: tester_V
  How to break a loop in this case? Blainexi 10 7,389 Sep-24-2020, 04:06 PM
Last Post: Blainexi
  how to break the loop? bntayfur 8 3,129 Jun-07-2020, 11:07 PM
Last Post: bntayfur
  break for loop Agusben 1 1,966 Apr-01-2020, 05:07 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020