1

Hello friends how can I update the window in tksheet. I have a database.Which connects to Postgresql and pulls out data. In addition, I can choose the date of the data, from which to which.After starting, I select the dates and click on the "Get data" button.The first time is displayed. After the first time, the data is not output to the interface.But it is displayed in the console. You can't select the date a second time and display it on the interface. I think that you need to update the window, if so, as soon as possible.

       def sec_frame(self):
           global date_from1, date_from2
           sec_frame1 = Frame(self.master, background='#21acfc', )
           sec_frame1.pack()

           query_button = tk.Button(sec_frame1, text='Get data', width=200, command=self.get_datas)
           query_button.pack(side=LEFT, padx=50, pady=40)

           date_from1 = DateEntry(sec_frame1, background='#e03aca', font="Helvetica 14", locale='KY')
           date_from1.pack(side=LEFT, padx=50)

           date_from2 = DateEntry(sec_frame1, background='#e03aca', font="Helvetica 14",locale='KY')
           date_from2.pack(side=LEFT)
     
    
        def get_datas(self):
            date1 = date_from.get_date()
            date2 = date_to.get_date()
            query_datas= f"select *from client_info where date_to='{date1}'::date and date_from='{date2}'::date"
            self.cursor.execute(query_datas)
            get_datas = self.cursor.fetchall()
            print(get_datas) #I actually get the data in the console
            try:
                get_datas[0]
            except IndexError:
                messagebox.showerror('some text', 'some text')
    
            lenn = len(get_datas)
            len1 = len(get_datas[0])
            bottom_frame = Frame(self.master, )
            table = Sheet(bottom_frame, page_up_down_select_row=True, column_width=120, startup_select=(0, 1, "rows"),
                          data=[[get_datas[r][c] for c in range(len1)] for r in range(lenn)],
                          height=1000,
                          width=1920
                          )
            table.enable_bindings(("single_select",
                                   "drag_select",
                                   "column_drag_and_drop",
                                   "row_drag_and_drop",
                                   "column_select",
                                   "row_select",
                                   "column_width_resize",
                                   "double_click_column_resize",
                                   "arrowkeys",
                                   "row_height_resize",
                                   "double_click_row_resize",
                                   "right_click_popup_menu",
                                   "rc_select",
                                   "rc_insert_column",
                                   "rc_delete_column",
                                   "rc_insert_row",
                                   "rc_delete_row",
                                   "hide_columns",
                                   "copy",
                                   ))
            bottom_frame.pack()
            table.pack(side=TOP)
Creator X
  • 41
  • 6
  • 1
    You created new big `table` (1920x1000) every time `get_datas()` is called and so the second table is *packed* outside the viewable area of the window. You should either delete the previous table or update the existing table. – acw1668 Dec 02 '20 at 08:28

1 Answers1

1

** thank you very much. You were right. I did this. In the sec_frame function, I created the global variables table, bottom_frame. I called these global variables in the get_datas function and passed an empty value to the table table.set_sheet_data(data=[]). Every time I click the button first, I pass empty data to the table. Then the received request passed again table. set_sheet_data(data=[......]).And at the end of bottom_frame, table made a pack() **

Creator X
  • 41
  • 6