So I've been trying to keep this program running once opened without idle,however I have used tinker buttons to be able to create a UI and will not work if a loop or sleep function after them
I am using python 3.12.3 on Windows 11
I tried to find a solution online, however I cant find anythingI have also tried putting the "make button" command in a loop / a loop after the "make button" command but it wont responda time.sleep() also doesn't work
(I know the code is a mess)
import timeimport turtlefrom turtle import Screenfrom tkinter import *screen = turtle.Screen()screen.setup(width=1000, height=400)screen.title("WBT war stat calculator")screen.bgcolor("light blue")canvas = screen.getcanvas()save_mil = ""save_diplo = ""save_eco = ""save_land = ""def update_total(): if not save_mil == "": if not save_diplo == "": if not save_eco == "": if not save_land == "": write_total.clear() stat1 = ((((save_eco / 3) * 2) + (save_diplo / 3) + save_mil) / 2) * save_land write_total.write(stat1, font=("Arial",30))def make_text(x, y): writer = turtle.Turtle() writer.penup() writer.speed(0) writer.hideturtle() writer.goto(x, y) return writerdef make_textbox(title1, des1, title2, des2, limit, type1): answer = screen.textinput(title1, des1) global save_mil global save_diplo global save_eco global save_land if answer == None: pass else: try: stat = float(answer) if stat > limit: pass else: if type1 == 1: save_mil = stat write_mil.clear() write_mil.write(stat, font=("Arial",30)) if type1 == 2: save_diplo = stat write_diplo.clear() write_diplo.write(stat, font=("Arial",30)) if type1 == 3: save_eco = stat write_eco.clear() write_eco.write(stat, font=("Arial",30)) if type1 == 4: save_land = stat write_land.clear() write_land.write(stat, font=("Arial",30)) update_total() except: stat = (limit + 1) while stat > limit: if answer == None: stat = 1 else: try: answer = screen.textinput(title2, des2) stat = float(answer) if stat > limit: pass else: if type1 == 1: save_mil = stat write_mil.clear() write_mil.write(stat, font=("Arial",30)) if type1 == 2: save_diplo = stat write_diplo.clear() write_diplo.write(stat, font=("Arial",30)) if type1 == 3: save_eco = stat write_eco.clear() write_eco.write(stat, font=("Arial",30)) if type1 == 4: save_land = stat write_land.clear() write_land.write(stat, font=("Arial",30)) update_total() except: passdef textbox_mil(): make_textbox(" ", "What are the military stats? 1 - 10", " ", "What are the military stats again? 1 - 10", 10, 1)def textbox_diplo(): make_textbox(" ", "Great, what are the diplomatic stats now? 1 - 10", " ", "Sorry, what are the diplomatic stats now? 1 - 10", 10, 2)def textbox_eco(): make_textbox(" ", "Eco stats? 1 - 10", " ", "Eco stats again? 1 - 10", 10, 3)def textbox_land(): make_textbox(" ", "How much of the earth do you have by percentage? (as decimal)", " ", "Repeat how much of the earth do you have by percentage? (as decimal)", 1, 4)def make_button(x_pos, y_pos, text_t, command_d): button = Button(canvas.master, text = text_t, command = command_d) button.pack() button.place(x = x_pos, y = y_pos)mil_button = make_button(100, 70, "Military", textbox_mil)diplo_button = make_button(100, 140, "Diplomatic", textbox_diplo)eco_button = make_button(100, 210, "Economic", textbox_eco)land_button = make_button(100, 280, "Land%", textbox_land)write_mil = make_text(-300, 100)write_diplo = make_text(-300, 30)write_eco = make_text(-300, -40)write_land = make_text(-300, -110)write_total = make_text(-90, -40)write_extra = make_text(-100, 200)write_extra.pendown()write_extra.goto(-100,-200)write_extra.penup()write_extra.goto(-90,100)write_extra.write("TOTAL:", font=("Arial",30))