-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with set_sheet_data #201
Comments
Hello and thank you very much for your report, I suspect this is a bug and I'll get back to you when I have fixed it |
@mithoon19 I am having some trouble reproducing the error myself, is there a way you could provide me a minimal example? I am currently using the below code on tksheet version # ruff: noqa
from tksheet import *
import tkinter as tk
import random
class demo(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.frame = tk.Frame(self)
self.frame.grid_columnconfigure(0, weight=1)
self.frame.grid_rowconfigure(0, weight=1)
self.sheet = Sheet(self.frame,
show_top_left=False,
show_row_index=False,
show_x_scrollbar=False,
show_y_scrollbar=False,
empty_horizontal=0,
empty_vertical=0,
headers=['1', '2', '3', '4', '5', '6', '7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22'],
theme="dark",
width=800,
height=200,
align="c")
self.sheet.set_column_widths([200, 80, 80, 80, 120, 100, 100, 100, 70, 70, 70, 70, 60, 70, 70, 70, 70, 70, 70, 50, 50, 50])
self.sheet.enable_bindings("all", "edit_index", "edit header", "ctrl_select")
self.sheet.popup_menu_add_command(
"test",
self.test,
table_menu=True,
header_menu=True,
empty_space_menu=True,
)
self.frame.grid(row=0, column=0, sticky="nswe")
self.sheet.grid(row=0, column=0, sticky="nswe")
def test(self, event=None):
t = random.randint(0, 500)
newdata = [[f"{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n" for c in range(22)] for r in range(30)]
self.sheet.headers([f"{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n{t}\n" for c in range(22)])
self.sheet.set_sheet_data(data=newdata, reset_col_positions=False)
app = demo()
app.mainloop() |
Thank you for quick response. I unable to reproduce the error. It just happens randomly. Most of the time it works just perfect. So, I am unable to figure out what could be the issue. |
Ok no worries in that case, just to check before I make some changes sorry, which version of tksheet are you using? |
I am using Version: 6.2.5 |
Address potential error with redrawing as described in issue #201 Also simplified some of the code involved with redrawing and removed unused classes as a result of changes
@mithoon19 The issue should be totally fixed in version Version 6.2.6Fixed:
Added:But please let me know if you encounter any issues! Thanks for your help |
Hello, good day.
First of all, Thank you for your amazing work.
I have a table and I keep refreshing it with new data. I use set_sheet_data to update data in table. I use below code to update sheet.
self.sheet.set_sheet_data(data=newdata, reset_col_positions=False)
Above code works most of the time. But, sometimes, I get below error and after which new values does not reflect automatically in my table. Table data gets updated with new values but does not get displayed. New updated values are displayed only after I click some cell.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\catuser\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "C:\Users\catuser\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 839, in callit
func(*args)
File "C:\Users\catuser\OneDrive\proj\lib\site-packages\tksheet_tksheet.py", line 383, in after_redraw
self.MT.main_table_redraw_grid_and_text(redraw_header=redraw_header, redraw_row_index=redraw_row_index)
File "C:\Users\catuser\OneDrive\proj\lib\site-packages\tksheet_tksheet_main_table.py", line 5461, in main_table_redraw_grid_and_text
self.CH.redraw_grid_and_text(
File "C:\Users\catuser\OneDrive\proj\lib\site-packages\tksheet_tksheet_column_headers.py", line 1626, in redraw_grid_and_text
iid, showing = self.hidd_text[k].pop()
KeyError: 'pop from an empty set'
I tested with delete_rows and then calling set_sheet_data. But, again received error sometimes.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\catuser\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "C:\Users\catuser\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 839, in callit
func(*args)
File "C:\Users\catuser\OneDrive\proj\lib\site-packages\tksheet_tksheet.py", line 383, in after_redraw
self.MT.main_table_redraw_grid_and_text(redraw_header=redraw_header, redraw_row_index=redraw_row_index)
File "C:\Users\catuser\OneDrive\proj\lib\site-packages\tksheet_tksheet_main_table.py", line 5351, in main_table_redraw_grid_and_text
iid, showing = self.hidd_text[k].pop()
KeyError: 'pop from an empty set'ty set'
I use below code to initialize my sheet.
The text was updated successfully, but these errors were encountered: