r/pythonhelp • • Aug 17 '20

Loops and tkinter act strange

I have made a bit of a program that tells you some prices with a tkinter window and then asks you how many of a commodity you want to buy. But after the first loop(you play several rounds) it stops waiting for an input. Let me know if you need code beyond this.

```

https://github.com/randomairborne/test/tree/master

```

3 Upvotes

2 comments sorted by

1

u/[deleted] Aug 17 '20

This also may spam you with windows because of this bug.

1

u/sentles Aug 18 '20

The problem is that whenever the user buys or sells anything, the oilbuy or oilsell functions are called. After this, things.cont is turned to False.

This is why it never stops at your loop at the end again, but just goes ahead and makes more and more windows. What you have to do is add things.cont = True after time.sleep(1).

This way, the next time it gets to the loop, it will stop again and wait for input.