Labels in Python Tkinter frames not being updated in for loop

I created a dictionary of python tkinter frames and when I try to loop through the frame to call a functions which updates the labels in each frame, only the last frame gets updated and rendered to the GUI window. This happens regardless of the number of frames in the dictionary. For example, if I have 2 frames, only the 2nd gets rendered, if I have 4 frames, only the 4th gets rendered to the GUI. What might be wrong?

I have tried to stop the loop from updating all the frames, such that it tries to only update the first frame in the dictionary (the dictionary still contains other frames). I did this because I suspected that the loop might be “forgetting” the previous labels when it proceeds to the next frame in the next iteration. The problem still persists, such that the first frame does not get updated and rendered, and since the last frame was not reached in the for loop, that also was not updated.

I have attached the relevant snippet of the code.

def create_monitor_page(self, monitor_location, monitor_no, job_type):
    command0 = "/path/to/dir " + monitor_location
    result0 = subprocess.run(command0, shell=True, capture_output=True, text=True)
    command1 = f"cat {monitor_location}/status_file"
    result1 = subprocess.run(command1, shell=True, capture_output=True, text=True)
    a = result1.stdout
    Label(monitor_canvas_dict_frame[f"{job_type}{monitor_no}"], text = f"Job Location ---> {monitor_location}", font = ("Times New Roman", 10, "bold")).grid(column = 1, row = 1, sticky = "w")
    Label(monitor_canvas_dict_frame[f"{job_type}{monitor_no}"], text = a, font = ("Times New Roman", 10, "bold")).grid(column = 1, row = 2, sticky = "w")
        
def refresh_monitor_info(self):
    jobs_dir = self.job_directory_server
    for jobs_type in os.listdir(jobs_dir):
        for individual_job in os.listdir(f"{jobs_dir}/{jobs_type}"):
            rm_other_files = f"rm {jobs_dir}/{jobs_type}/{individual_job}/builds/status_file"
            subprocess.run(rm_other_files, shell=True, capture_output=True, text=True)
            ls_command = f"ls {jobs_dir}/{jobs_type}/{individual_job}/builds"
            execute_command = subprocess.run(ls_command, shell=True, capture_output=True, text=True)
            job_name = execute_command.stdout
            self.monitoring.create_monitor_page(f"{jobs_dir}/{jobs_type}/{individual_job}/builds/{job_name[:-1]}", int(re.search(r'd+', individual_job).group()), jobs_type)

file_counter = 0
for files in os.listdir(script_directory):
    monitor_frames_dict[f"server{file_counter}"] = Frame(launcher_obj.notebook)
    launcher_obj.notebook.add(monitor_frames_dict[f"server{file_counter}"], text=f"Monitor{file_counter}_server")
    monitor_canvas_dict[f"server{file_counter}"] = Canvas(monitor_frames_dict[f"server{file_counter}"])
    server_project_vertical_scrollbar = Scrollbar(monitor_frames_dict[f"server{file_counter}"], orient=VERTICAL,
                                                command=monitor_canvas_dict[f"server{file_counter}"].yview)
    server_project_horizontal_scrollbar = Scrollbar(monitor_frames_dict[f"server{file_counter}"], orient=HORIZONTAL,
                                                  command=monitor_canvas_dict[f"server{file_counter}"].xview)
    monitor_canvas_dict[f"server{file_counter}"].grid(row=0, column=0, sticky="nsew")
    monitor_canvas_dict[f"server{file_counter}"].bind("<Configure>",
                             lambda cc: monitor_canvas_dict[f"server{file_counter-1}"].config(width=cc.width, height=cc.height))
    monitor_canvas_dict_frame[f"server{file_counter}"] = Frame(monitor_canvas_dict[f"server{file_counter}"])
    monitor_canvas_dict_frame[f"server{file_counter}"].bind("<Configure>", lambda e: monitor_canvas_dict[f"server{file_counter-1}"].configure(scrollregion=monitor_canvas_dict[f"server{file_counter-1}"].bbox("all")))
    monitor_canvas_dict[f"server{file_counter}"].create_window((0, 0), window=monitor_canvas_dict_frame[f"server{file_counter}"])
    monitor_canvas_dict[f"server{file_counter}"].configure(yscrollcommand=server_project_vertical_scrollbar.set)
    monitor_canvas_dict[f"server{file_counter}"].configure(xscrollcommand=server_project_horizontal_scrollbar.set)
    server_project_horizontal_scrollbar.pack(side="bottom", fill="x")
    server_project_vertical_scrollbar.pack(side="right", fill="y")
    monitor_canvas_dict[f"server{file_counter}"].pack(side="left", fill="both", expand=True)
    launcher_obj.notebook.select(launcher_obj.notebook.index(tkinter.END) - 1)
    launcher_obj.main_treeview.insert("server_monitor", 'end', iid=f"Monitor{file_counter}_server", text=f"Monitor{file_counter}_server")
    
    file_counter = file_counter + 1


5

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