tksheet 7.3.0__py3-none-any.whl → 7.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tksheet/__init__.py +2 -2
- tksheet/column_headers.py +41 -40
- tksheet/find_window.py +251 -0
- tksheet/formatters.py +1 -1
- tksheet/functions.py +80 -50
- tksheet/main_table.py +531 -286
- tksheet/other_classes.py +6 -9
- tksheet/row_index.py +43 -40
- tksheet/sheet.py +165 -75
- tksheet/sheet_options.py +30 -1
- tksheet/text_editor.py +1 -1
- tksheet/top_left_rectangle.py +1 -1
- tksheet/types.py +8 -0
- {tksheet-7.3.0.dist-info → tksheet-7.3.2.dist-info}/METADATA +10 -11
- tksheet-7.3.2.dist-info/RECORD +21 -0
- {tksheet-7.3.0.dist-info → tksheet-7.3.2.dist-info}/WHEEL +1 -1
- tksheet-7.3.0.dist-info/RECORD +0 -20
- /tksheet/{vars.py → constants.py} +0 -0
- {tksheet-7.3.0.dist-info → tksheet-7.3.2.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.3.0.dist-info → tksheet-7.3.2.dist-info}/top_level.txt +0 -0
tksheet/other_classes.py
CHANGED
@@ -457,7 +457,7 @@ class Node:
|
|
457
457
|
return self.text
|
458
458
|
|
459
459
|
|
460
|
-
class
|
460
|
+
class StorageBase:
|
461
461
|
__slots__ = ("canvas_id", "window", "open")
|
462
462
|
|
463
463
|
def __init__(self) -> None:
|
@@ -465,6 +465,8 @@ class DropdownStorage:
|
|
465
465
|
self.window = None
|
466
466
|
self.open = False
|
467
467
|
|
468
|
+
|
469
|
+
class DropdownStorage(StorageBase):
|
468
470
|
def get_coords(self) -> int | tuple[int, int] | None:
|
469
471
|
"""
|
470
472
|
Returns None if not open or window is None
|
@@ -474,14 +476,7 @@ class DropdownStorage:
|
|
474
476
|
return None
|
475
477
|
|
476
478
|
|
477
|
-
class
|
478
|
-
__slots__ = ("canvas_id", "window", "open")
|
479
|
-
|
480
|
-
def __init__(self) -> None:
|
481
|
-
self.canvas_id = None
|
482
|
-
self.window = None
|
483
|
-
self.open = False
|
484
|
-
|
479
|
+
class EditorStorageBase(StorageBase):
|
485
480
|
def focus(self) -> None:
|
486
481
|
if self.window:
|
487
482
|
self.window.tktext.focus_set()
|
@@ -516,6 +511,8 @@ class TextEditorStorage:
|
|
516
511
|
return self.window.tktext
|
517
512
|
return self.window
|
518
513
|
|
514
|
+
|
515
|
+
class TextEditorStorage(EditorStorageBase):
|
519
516
|
@property
|
520
517
|
def coords(self) -> tuple[int, int]:
|
521
518
|
return self.window.r, self.window.c
|
tksheet/row_index.py
CHANGED
@@ -5,7 +5,6 @@ from collections import defaultdict
|
|
5
5
|
from collections.abc import (
|
6
6
|
Generator,
|
7
7
|
Hashable,
|
8
|
-
Iterator,
|
9
8
|
Sequence,
|
10
9
|
)
|
11
10
|
from functools import (
|
@@ -29,19 +28,29 @@ from typing import Literal
|
|
29
28
|
from .colors import (
|
30
29
|
color_map,
|
31
30
|
)
|
31
|
+
from .constants import (
|
32
|
+
rc_binding,
|
33
|
+
text_editor_close_bindings,
|
34
|
+
text_editor_newline_bindings,
|
35
|
+
text_editor_to_unbind,
|
36
|
+
)
|
32
37
|
from .formatters import (
|
33
38
|
is_bool_like,
|
34
39
|
try_to_bool,
|
35
40
|
)
|
36
41
|
from .functions import (
|
37
42
|
consecutive_chunks,
|
43
|
+
consecutive_ranges,
|
38
44
|
event_dict,
|
45
|
+
event_has_char_key,
|
46
|
+
event_opens_dropdown_or_checkbox,
|
39
47
|
get_n2a,
|
48
|
+
int_x_tuple,
|
40
49
|
is_contiguous,
|
41
50
|
new_tk_event,
|
42
51
|
num2alpha,
|
43
|
-
stored_event_dict,
|
44
52
|
rounded_box_coords,
|
53
|
+
stored_event_dict,
|
45
54
|
try_binding,
|
46
55
|
)
|
47
56
|
from .other_classes import (
|
@@ -54,12 +63,8 @@ from .other_classes import (
|
|
54
63
|
from .text_editor import (
|
55
64
|
TextEditor,
|
56
65
|
)
|
57
|
-
from .
|
58
|
-
|
59
|
-
symbols_set,
|
60
|
-
text_editor_close_bindings,
|
61
|
-
text_editor_newline_bindings,
|
62
|
-
text_editor_to_unbind,
|
66
|
+
from .types import (
|
67
|
+
AnyIter,
|
63
68
|
)
|
64
69
|
|
65
70
|
|
@@ -944,20 +949,31 @@ class RowIndex(tk.Canvas):
|
|
944
949
|
|
945
950
|
def select_row(
|
946
951
|
self,
|
947
|
-
r: int,
|
952
|
+
r: int | AnyIter[int],
|
948
953
|
redraw: bool = False,
|
949
954
|
run_binding_func: bool = True,
|
950
955
|
ext: bool = False,
|
951
956
|
) -> int:
|
952
957
|
boxes_to_hide = tuple(self.MT.selection_boxes)
|
953
|
-
|
958
|
+
fill_iids = [
|
959
|
+
self.MT.create_selection_box(
|
960
|
+
start,
|
961
|
+
0,
|
962
|
+
end,
|
963
|
+
len(self.MT.col_positions) - 1,
|
964
|
+
"rows",
|
965
|
+
set_current=True,
|
966
|
+
ext=ext,
|
967
|
+
)
|
968
|
+
for start, end in consecutive_ranges(int_x_tuple(r))
|
969
|
+
]
|
954
970
|
for iid in boxes_to_hide:
|
955
971
|
self.MT.hide_selection_box(iid)
|
956
972
|
if redraw:
|
957
973
|
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
|
958
974
|
if run_binding_func:
|
959
975
|
self.MT.run_selection_binding("rows")
|
960
|
-
return
|
976
|
+
return fill_iids[0] if len(fill_iids) == 1 else fill_iids
|
961
977
|
|
962
978
|
def add_selection(
|
963
979
|
self,
|
@@ -1113,7 +1129,7 @@ class RowIndex(tk.Canvas):
|
|
1113
1129
|
|
1114
1130
|
def get_index_text_width(
|
1115
1131
|
self,
|
1116
|
-
only_rows:
|
1132
|
+
only_rows: AnyIter[int] | None = None,
|
1117
1133
|
) -> int:
|
1118
1134
|
self.fix_index()
|
1119
1135
|
w = self.PAR.ops.default_row_index_width
|
@@ -1199,6 +1215,8 @@ class RowIndex(tk.Canvas):
|
|
1199
1215
|
if new_w is not None and (sheet_w_x := floor(self.PAR.winfo_width() * 0.7)) < new_w:
|
1200
1216
|
new_w = sheet_w_x
|
1201
1217
|
if new_w and (self.current_width - new_w > 20 or new_w - self.current_width > 3):
|
1218
|
+
if self.MT.find_window.open:
|
1219
|
+
self.MT.itemconfig(self.MT.find_window.canvas_id, state="hidden")
|
1202
1220
|
self.set_width(new_w, set_TL=True, recreate_selection_boxes=False)
|
1203
1221
|
return True
|
1204
1222
|
return False
|
@@ -1812,8 +1830,8 @@ class RowIndex(tk.Canvas):
|
|
1812
1830
|
|
1813
1831
|
def get_redraw_selections(self, startr: int, endr: int) -> dict[str, set[int]]:
|
1814
1832
|
d = defaultdict(set)
|
1815
|
-
for
|
1816
|
-
r1,
|
1833
|
+
for _, box in self.MT.get_selection_items():
|
1834
|
+
r1, _, r2, _ = box.coords
|
1817
1835
|
for r in range(startr, endr):
|
1818
1836
|
if r1 <= r and r2 > r:
|
1819
1837
|
d[box.type_ if box.type_ != "columns" else "cells"].add(r)
|
@@ -1829,7 +1847,7 @@ class RowIndex(tk.Canvas):
|
|
1829
1847
|
if self.get_cell_kwargs(datarn, key="readonly"):
|
1830
1848
|
return
|
1831
1849
|
elif self.get_cell_kwargs(datarn, key="dropdown") or self.get_cell_kwargs(datarn, key="checkbox"):
|
1832
|
-
if
|
1850
|
+
if event_opens_dropdown_or_checkbox(event):
|
1833
1851
|
if self.get_cell_kwargs(datarn, key="dropdown"):
|
1834
1852
|
self.open_dropdown_window(r, event=event)
|
1835
1853
|
elif self.get_cell_kwargs(datarn, key="checkbox"):
|
@@ -1855,28 +1873,16 @@ class RowIndex(tk.Canvas):
|
|
1855
1873
|
state: str = "normal",
|
1856
1874
|
dropdown: bool = False,
|
1857
1875
|
) -> bool:
|
1858
|
-
text =
|
1876
|
+
text = f"{self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)}"
|
1859
1877
|
extra_func_key = "??"
|
1860
|
-
if
|
1861
|
-
if event
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
elif event is not None
|
1868
|
-
(hasattr(event, "keysym") and event.keysym == "BackSpace") or event.keycode in (8, 855638143)
|
1869
|
-
):
|
1870
|
-
extra_func_key = "BackSpace"
|
1871
|
-
text = ""
|
1872
|
-
elif event is not None and (
|
1873
|
-
(hasattr(event, "char") and event.char.isalpha())
|
1874
|
-
or (hasattr(event, "char") and event.char.isdigit())
|
1875
|
-
or (hasattr(event, "char") and event.char in symbols_set)
|
1876
|
-
):
|
1877
|
-
extra_func_key = event.char
|
1878
|
-
text = event.char
|
1879
|
-
else:
|
1878
|
+
if event_opens_dropdown_or_checkbox(event):
|
1879
|
+
if hasattr(event, "keysym") and event.keysym in ("Return", "F2", "BackSpace"):
|
1880
|
+
extra_func_key = event.keysym
|
1881
|
+
if event.keysym == "BackSpace":
|
1882
|
+
text = ""
|
1883
|
+
elif event_has_char_key(event):
|
1884
|
+
extra_func_key = text = event.char
|
1885
|
+
elif event is not None:
|
1880
1886
|
return False
|
1881
1887
|
if self.extra_begin_edit_cell_func:
|
1882
1888
|
try:
|
@@ -1898,12 +1904,11 @@ class RowIndex(tk.Canvas):
|
|
1898
1904
|
return False
|
1899
1905
|
else:
|
1900
1906
|
text = text if isinstance(text, str) else f"{text}"
|
1901
|
-
text = "" if text is None else text
|
1902
1907
|
if self.PAR.ops.cell_auto_resize_enabled:
|
1903
1908
|
self.set_row_height_run_binding(r)
|
1904
1909
|
if self.text_editor.open and r == self.text_editor.row:
|
1905
1910
|
self.text_editor.set_text(self.text_editor.get() + "" if not isinstance(text, str) else text)
|
1906
|
-
return
|
1911
|
+
return False
|
1907
1912
|
self.hide_text_editor()
|
1908
1913
|
if not self.MT.see(r=r, c=0, keep_yscroll=True, check_cell_visibility=True):
|
1909
1914
|
self.MT.refresh()
|
@@ -1911,8 +1916,6 @@ class RowIndex(tk.Canvas):
|
|
1911
1916
|
y = self.MT.row_positions[r]
|
1912
1917
|
w = self.current_width + 1
|
1913
1918
|
h = self.MT.row_positions[r + 1] - y + 1
|
1914
|
-
if text is None:
|
1915
|
-
text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
|
1916
1919
|
kwargs = {
|
1917
1920
|
"menu_kwargs": DotDict(
|
1918
1921
|
{
|