Skip to content

loading time in a large number of records #88

Description

@hassan-anari

header:
Hello, first of all, you need to take a look at this post:
TomSchimansky/CustomTkinter#431 (comment)

body:
As it was explained, when the number of our records is large, for example a thousand... the use of the program is not optimal and it is slow.
I thought to solve this problem and that is that we should not show all the items at the same time and it is better to show 10 items at a time and design pages based on the number of records and move between pages. For example, our 1000 records are divided into 100 pages, each of which displays 10 records. I think that problem will be solved in this case.
I wanted to get your help on how I can implement this idea?
thank you

  • i hope you understand.

Activity

  1. Akascape commented on Apr 17, 2024

    @Akascape
    Owner

    Here is an example for the page implementation in ctktable,

    import customtkinter
    from CTkTable import *
    
    def change_left():
        global current_page
        current_page -= 4 # move 4 rows backward
        table.update_values(values[current_page-4:current_page])
        pass
    
    def change_right():
        global current_page
        current_page += 4 # move 4 rows forward
        table.update_values(values[current_page-4:current_page])
        pass
    
    root = customtkinter.CTk()
    
    current_page = 0
    
    # Make a long list
    values = []
    start = 0
    end = 5
    
    for i in range(20):
        values.append(list(range(start, end)))
        start = end
        end += 5
        
    
    table = CTkTable(master=root, row=4, column=5)
    table.pack(expand=True, fill="both", padx=20, pady=20)
    
    customtkinter.CTkButton(root, text="<", width=40, command=change_left).pack(side="left", expand=True, pady=10)
    customtkinter.CTkButton(root, text=">", width=40, command=change_right).pack(side="right", expand=True, pady=10)
    change_right()
    
    root.mainloop()
  2. Repository owner locked and limited conversation to collaborators on Apr 17, 2024
  3. converted this issue into a discussion #89 on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions