[Python] Infinite LOOP function [closed]

Discussão em 'Python' iniciado por Stack, Junho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am writing a sort-of complex but mostly simple program in python.

    When I use the LOOP function in the code shown below, and nest it into itself, it repeats infinitely. I have given up on other methods to figure out the problem, and have resorted to Stack Overflow. Can anybody help me?

    import tkinter as tk
    import sklearn as sk
    import re
    from numba import cuda
    import threading

    root = tk.Tk()
    root.title("gVars (glowfroot visualization and rendering system)")

    frame = tk.Canvas(root)
    frame.grid(row=2, column=1)

    text = tk.Text(root)
    text.grid(row=2, column=0)

    label = tk.Label(root, text="No errors yet!")
    label.grid(row=3, column=0)

    def SubmitCode():
    code = text.get('1.0', "end")
    return code

    def Create_Pixel(x, y, color):
    frame.create_rectangle(x, y, x, y, fill=color, outline="")


    def ParseCode(code3, array):
    try:
    x = 0
    y = 0
    if (code3[0] == "PIX"):
    if(code3[1] in array):
    x = float(array[code3[1]])
    else:
    x = float(code3[1])

    if(code3[2] in array):
    y = float(array[code3[2]])
    else:
    y = float(code3[2])


    Create_Pixel(x, y, code3[3])

    except Exception as exc:
    print(exc)
    label.config(text=str(exc))
    print("You found this at the PIX function!")

    def ExecCode():
    k = 0
    kbool = False
    code = SubmitCode()
    array = {}
    code0 = code.strip().split('\n')
    j = 0
    stack = []
    while j < len(code0):
    code05 = code0[j]
    code1 = code05.split(';')
    i = 0
    while i < len(code1):

    code2 = code1
    code3 = code2.split(' ')

    if(code3[0] == "LOOP"):

    print("stack is 0")
    stack.append(code3[2])
    stack[-1] = int(stack[-1])
    stack[-1] -= 1

    if(int(stack[-1]) > 0):
    j = int(code3[1]) - 2
    else:
    stack.pop()


    if(code3[0] == "SET"):
    array[code3[1]] = code3[2]
    elif (code3[0] == "PLUS"):
    array[str(code3[1])] = float(array.get(str(code3[1]), 0)) + float(code3[2])
    elif (code3[0] == "TIMES"):
    array[str(code3[1])] = float(array.get(str(code3[1]), 0)) * float(code3[2])
    else:
    ParseCode(code3, array)
    k += 1;
    i += 1
    j += 1

    def DeleteCode():
    frame.delete("all")

    send = tk.Button(text="Send over", command=ExecCode)
    send.grid(row=0, column=0)

    delete = tk.Button(text="Delete image", command=DeleteCode)
    delete.grid(row=0, column=1)

    root.mainloop()


    Ignore the variables and stuff that I forgot to take out. The only thing I am focusing on is the LOOP function. ParseCode() draws a pixel with a "PIX" function, and I know the problem is not with that. Thanks!

    Continue reading...

Compartilhe esta Página