Skip to content
Advertisement

Start and stop command to break a loop

I’m working on a webscraping code, and the process is quite long. Thus, I would like to start and stop it in a fancy way, with a button using tkinter. But I couldn’t find any solution on the web.

  • The .after() function doesn’t seems to be a good option as I don’t want to restart my loop each time. My loop is already working based on urls readed from another document and parsing for each.
  • I tried the thread option with .join(). But couldn’t manage to solve my problem with it. But maybe I don’t write my code correctly.

My problem can be formulate as follow:

Start → Read urls doc and launch parsing loop.

Stop → Stop parsing and save content.

For instance I would like something like the following code to work:

JavaScript

Advertisement

Answer

Ok I managed to solve the problem, using a flag system indeed.

JavaScript

Thanks for your help it was helpfull.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement