Why does my python program start another instance of itself at a button click?

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…

New contributor

snoms is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật