Skip to content Skip to sidebar Skip to footer

While Loop In Tkinter (python)

This just keeps freezing. The while loop does not run and I think that's the problem from Tkinter import* def reveal(): counter=0 lowest=0 Stotal=0 i=0 cost=

Solution 1:

This code is the problem:

while i==0:
    cost=float(cost_ent.get())
    if cost>0:
        counter+=1
        Stotal=cost+Stotal
        if cost<lowest:
            lowest=cost
    else:
        message="Invalid Number"
        txt.insert(0.0, message)

i is never changed. It will always be zero, so the loop never terminates.

(you also have a bug in that you're using 0.0 as the starting index, but tkinter text indexes should be strings, and the line numbers start counting at one, not zero.)

Post a Comment for "While Loop In Tkinter (python)"