Every time I click a button in the app I am currently working on, the program goes to “no response” and then launches another instance of itself while the old one is still active. I don’t know how or why because while having it run inside the IDE it works. As soon as I pack it with auto-py-to-exe, it does this.
The code for the Button:
info_but = customtkinter.CTkButton(menu,text="", font=custom_font,
image=info_def,bg_color="#FDF6E4",fg_color="#FDF6E4",hover_color="#3b444b",
width=70, command= info_menu,height=70)
info_but.place(x=20, y=220)
The function getting called is just responsible for placing labels. Only stuff happening there is:
os_ver = f"{uname().system} {uname().release}" # get_gpu_models()
threaded_check_for_new_version(repo_owner, repo_name, current_version)
proc_info = cpuinfo.get_cpu_info()
ram = psutil.virtual_memory()
affecting:
def fetch_latest_version(repo_owner, repo_name, current_version):
global cached_result
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest"
response = requests.get(url)
if response.status_code == 200:
latest_version = response.json().get('tag_name')
comparison_result = semver.compare(current_version, latest_version)
if comparison_result < 0:
cached_result = [True, latest_version]
elif comparison_result == 0:
cached_result = [False, latest_version]
else:
cached_result = [False, current_version] # Deine Version ist neuer
else:
cached_result = [False, None]
update_label_text()
def update_label_text():
global cached_result, update_label
if cached_result[0]:
update_label.configure(text="Yes")
else:
if cached_result[1] is None:
update_label.configure(text="Error")
else:
update_label.configure(text="No")
root.update()
def check_for_new_version(repo_owner, repo_name, current_version):
global cached_result, cache_lock
root.update()
with cache_lock:
if cached_result[1] is None:
fetch_latest_version(repo_owner, repo_name, current_version)
else:
update_label_text()
def threaded_check_for_new_version(repo_owner, repo_name, current_version):
thread = threading.Thread(target=check_for_new_version, args=(repo_owner, repo_name, current_version))
thread.start()
def fetch_gpu_models(result):
try:
gpus = GPUtil.getGPUs()
gpu_models = set(gpu.name for gpu in gpus)
result.append(list(gpu_models) if gpu_models else ["Unknown"])
except Exception as e:
result.append(["Unknown"])
update_model_label(gpu_label,result[0])
def update_model_label(gpu_label,gpu_models):
gpu_label.configure(text=f"{gpu_models[0]}")
root.update()
def get_gpu_models(gpu_label):
result = []
fetch_gpu_models(result)
return result[0] if result else ["Unknown"]
def threaded_get_gpu_models(gpu_label):
thread = threading.Thread(target=get_gpu_models, args=(gpu_label,))
thread.start()
I fixed all errors the IDE threw at me when I clicked the button like thread handling and such, but still no luck. I also changed the names of the variable and function because I noticed that I (stupid) used the name multiple times for different things…
snoms is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.