ragardner / tksheet

Python tkinter table widget for displaying tabular data
https://pypi.org/project/tksheet/
MIT License
408 stars 50 forks source link

Editing out of bounds when changing sheets #222

Closed MagnificentCreature closed 6 months ago

MagnificentCreature commented 6 months ago

https://github.com/ragardner/tksheet/assets/61371541/4908ca25-4fd3-4a67-abf6-2f85b70ac932

This issue came with a small modification of the code here https://github.com/ragardner/tksheet/wiki/Version-7#example-saving-tksheet-as-a-csv-file

bind open_csv to ctrl+o

self.bind("", lambda e: self.open_csv())

I added this line.

The issue lies that when I switch the sheet data, my old edit entry stays and cause bugs.

It would override data in the new sheet or might cause out of bounds issue,

Reset highilght and reset does not fix this are there any solutions?

Python\Python310\lib\site-packages\tksheet\main_table.py", line 3587, in set_cell_size_to_text
    if h > self.row_positions[r + 1] - self.row_positions[r]:
IndexError: list index out of range

This is the error I get when I try exitting in the new sheet

Thank you

ragardner commented 6 months ago

Hello,

Thanks for bringing this issue to my attention and for the helpful video and explanation,

The solution I used to address this in version 7.1.22 released just now was to hide the text editor when setting sheet data, I am not entirely sure this has fixed the issue however as it was difficult to recreate the exact behaviour in the video

Please let me know if this solution is not ideal or you're still having issues and I will take another look

MagnificentCreature commented 6 months ago

Yes, this fixed the issue, thank you!