tksheet 7.1.5__py3-none-any.whl → 7.1.7__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 +99 -96
- tksheet/column_headers.py +63 -44
- tksheet/functions.py +27 -15
- tksheet/listbox.py +19 -0
- tksheet/main_table.py +407 -315
- tksheet/row_index.py +85 -48
- tksheet/sheet.py +74 -81
- tksheet/sheet_options.py +3 -1
- {tksheet-7.1.5.dist-info → tksheet-7.1.7.dist-info}/METADATA +1 -1
- tksheet-7.1.7.dist-info/RECORD +21 -0
- tksheet-7.1.5.dist-info/RECORD +0 -20
- {tksheet-7.1.5.dist-info → tksheet-7.1.7.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.1.5.dist-info → tksheet-7.1.7.dist-info}/WHEEL +0 -0
- {tksheet-7.1.5.dist-info → tksheet-7.1.7.dist-info}/top_level.txt +0 -0
tksheet/row_index.py
CHANGED
@@ -18,6 +18,7 @@ from math import (
|
|
18
18
|
ceil,
|
19
19
|
floor,
|
20
20
|
)
|
21
|
+
from typing import Literal
|
21
22
|
|
22
23
|
from .colors import (
|
23
24
|
color_map,
|
@@ -30,7 +31,7 @@ from .functions import (
|
|
30
31
|
consecutive_chunks,
|
31
32
|
ev_stack_dict,
|
32
33
|
event_dict,
|
33
|
-
|
34
|
+
rounded_box_coords,
|
34
35
|
get_n2a,
|
35
36
|
is_contiguous,
|
36
37
|
num2alpha,
|
@@ -404,7 +405,7 @@ class RowIndex(tk.Canvas):
|
|
404
405
|
):
|
405
406
|
self.open_cell(event)
|
406
407
|
elif (iid := self.event_over_tree_arrow(r, self.canvasy(event.y), event.x)) is not None:
|
407
|
-
self.PAR.item(iid, open_=iid not in self.tree_open_ids)
|
408
|
+
self.PAR.item(iid, open_=iid not in self.tree_open_ids, redraw=False)
|
408
409
|
self.rsz_h = None
|
409
410
|
self.mouse_motion(event)
|
410
411
|
try_binding(self.extra_double_b1_func, event)
|
@@ -866,7 +867,9 @@ class RowIndex(tk.Canvas):
|
|
866
867
|
):
|
867
868
|
self.open_cell(event)
|
868
869
|
elif (iid := self.event_over_tree_arrow(r, canvasy, event.x)) is not None:
|
869
|
-
self.
|
870
|
+
if self.MT.selection_boxes:
|
871
|
+
self.select_row(r, redraw=False)
|
872
|
+
self.PAR.item(iid, open_=iid not in self.tree_open_ids, redraw=False)
|
870
873
|
else:
|
871
874
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
872
875
|
self.b1_pressed_loc = None
|
@@ -955,14 +958,33 @@ class RowIndex(tk.Canvas):
|
|
955
958
|
outline: str,
|
956
959
|
state: str,
|
957
960
|
tags: str | tuple[str],
|
961
|
+
iid: None | int = None,
|
958
962
|
) -> int:
|
959
|
-
|
960
|
-
|
961
|
-
|
963
|
+
coords = rounded_box_coords(
|
964
|
+
x1,
|
965
|
+
y1,
|
966
|
+
x2,
|
967
|
+
y2,
|
968
|
+
radius=9 if self.PAR.ops.rounded_boxes else 0,
|
969
|
+
)
|
970
|
+
if isinstance(iid, int):
|
971
|
+
self.coords(iid, coords)
|
962
972
|
self.itemconfig(iid, fill=fill, outline=outline, state=state, tags=tags)
|
963
973
|
else:
|
964
|
-
|
965
|
-
|
974
|
+
if self.hidd_boxes:
|
975
|
+
iid = self.hidd_boxes.pop()
|
976
|
+
self.coords(iid, coords)
|
977
|
+
self.itemconfig(iid, fill=fill, outline=outline, state=state, tags=tags)
|
978
|
+
else:
|
979
|
+
iid = self.create_polygon(
|
980
|
+
coords,
|
981
|
+
fill=fill,
|
982
|
+
outline=outline,
|
983
|
+
state=state,
|
984
|
+
tags=tags,
|
985
|
+
smooth=True,
|
986
|
+
)
|
987
|
+
self.disp_boxes.add(iid)
|
966
988
|
return iid
|
967
989
|
|
968
990
|
def hide_box(self, item: int | None) -> None:
|
@@ -1014,11 +1036,10 @@ class RowIndex(tk.Canvas):
|
|
1014
1036
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
1015
1037
|
start_col, end_col = self.MT.get_visible_columns(x1, x2)
|
1016
1038
|
else:
|
1017
|
-
|
1018
|
-
0,
|
1019
|
-
|
1020
|
-
|
1021
|
-
iterable = range(start_col, end_col)
|
1039
|
+
if not self.MT.data or datarn >= len(self.MT.data):
|
1040
|
+
iterable = range(0, 0)
|
1041
|
+
else:
|
1042
|
+
iterable = range(0, len(self.MT.data[datarn]))
|
1022
1043
|
else:
|
1023
1044
|
if displayed_only:
|
1024
1045
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
@@ -1339,7 +1360,7 @@ class RowIndex(tk.Canvas):
|
|
1339
1360
|
self.disp_dropdown[t] = True
|
1340
1361
|
|
1341
1362
|
def redraw_checkbox(self, x1, y1, x2, y2, fill, outline, tag, draw_check=False):
|
1342
|
-
points =
|
1363
|
+
points = rounded_box_coords(x1, y1, x2, y2)
|
1343
1364
|
if self.hidd_checkbox:
|
1344
1365
|
t, sh = self.hidd_checkbox.popitem()
|
1345
1366
|
self.coords(t, points)
|
@@ -1357,7 +1378,7 @@ class RowIndex(tk.Canvas):
|
|
1357
1378
|
y1 = y1 + 4
|
1358
1379
|
x2 = x2 - 3
|
1359
1380
|
y2 = y2 - 3
|
1360
|
-
points =
|
1381
|
+
points = rounded_box_coords(x1, y1, x2, y2, radius=4)
|
1361
1382
|
if self.hidd_checkbox:
|
1362
1383
|
t, sh = self.hidd_checkbox.popitem()
|
1363
1384
|
self.coords(t, points)
|
@@ -1657,16 +1678,14 @@ class RowIndex(tk.Canvas):
|
|
1657
1678
|
dct[iid] = False
|
1658
1679
|
return True
|
1659
1680
|
|
1660
|
-
def get_redraw_selections(self, startr, endr):
|
1661
|
-
d = defaultdict(
|
1681
|
+
def get_redraw_selections(self, startr: int, endr: int) -> dict[str, set[int]]:
|
1682
|
+
d = defaultdict(set)
|
1662
1683
|
for item, box in self.MT.get_selection_items(columns=False):
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
d2["rows"] = {r for r in range(startr, endr) for r1, c1, r2, c2 in d["rows"] if r1 <= r and r2 > r}
|
1669
|
-
return d2
|
1684
|
+
r1, c1, r2, c2 = box.coords
|
1685
|
+
for r in range(startr, endr):
|
1686
|
+
if r1 <= r and r2 > r:
|
1687
|
+
d[box.type_].add(r)
|
1688
|
+
return d
|
1670
1689
|
|
1671
1690
|
def open_cell(self, event: object = None, ignore_existing_editor=False):
|
1672
1691
|
if not self.MT.anything_selected() or (not ignore_existing_editor and self.text_editor.open):
|
@@ -1712,8 +1731,7 @@ class RowIndex(tk.Canvas):
|
|
1712
1731
|
extra_func_key = "Return"
|
1713
1732
|
elif hasattr(event, "keysym") and event.keysym == "F2":
|
1714
1733
|
extra_func_key = "F2"
|
1715
|
-
|
1716
|
-
text = self.get_cell_data(datarn, none_to_empty_str=True, redirect_int=True)
|
1734
|
+
text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
|
1717
1735
|
elif event is not None and (
|
1718
1736
|
(hasattr(event, "keysym") and event.keysym == "BackSpace") or event.keycode in (8, 855638143)
|
1719
1737
|
):
|
@@ -1761,9 +1779,8 @@ class RowIndex(tk.Canvas):
|
|
1761
1779
|
y = self.MT.row_positions[r]
|
1762
1780
|
w = self.current_width + 1
|
1763
1781
|
h = self.MT.row_positions[r + 1] - y + 1
|
1764
|
-
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1765
1782
|
if text is None:
|
1766
|
-
text = self.get_cell_data(datarn, none_to_empty_str=True, redirect_int=True)
|
1783
|
+
text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
|
1767
1784
|
bg, fg = self.PAR.ops.index_bg, self.PAR.ops.index_fg
|
1768
1785
|
kwargs = {
|
1769
1786
|
"menu_kwargs": DotDict(
|
@@ -1820,7 +1837,7 @@ class RowIndex(tk.Canvas):
|
|
1820
1837
|
not check_lines
|
1821
1838
|
or self.MT.get_lines_cell_height(
|
1822
1839
|
self.text_editor.window.get_num_lines() + 1,
|
1823
|
-
font=self.
|
1840
|
+
font=self.text_editor.tktext.cget("font"),
|
1824
1841
|
)
|
1825
1842
|
> curr_height
|
1826
1843
|
):
|
@@ -1851,24 +1868,30 @@ class RowIndex(tk.Canvas):
|
|
1851
1868
|
)
|
1852
1869
|
self.itemconfig(self.dropdown.canvas_id, anchor=anchor, height=win_h)
|
1853
1870
|
|
1854
|
-
def refresh_open_window_positions(self):
|
1871
|
+
def refresh_open_window_positions(self, zoom: Literal["in", "out"]):
|
1855
1872
|
if self.text_editor.open:
|
1856
1873
|
r = self.text_editor.row
|
1857
1874
|
self.text_editor.window.config(height=self.MT.row_positions[r + 1] - self.MT.row_positions[r])
|
1875
|
+
self.text_editor.tktext.config(font=self.PAR.ops.index_font)
|
1858
1876
|
self.coords(
|
1859
1877
|
self.text_editor.canvas_id,
|
1860
1878
|
0,
|
1861
1879
|
self.MT.row_positions[r],
|
1862
1880
|
)
|
1863
1881
|
if self.dropdown.open:
|
1882
|
+
if zoom == "in":
|
1883
|
+
self.dropdown.window.zoom_in()
|
1884
|
+
elif zoom == "out":
|
1885
|
+
self.dropdown.window.zoom_out()
|
1864
1886
|
r = self.dropdown.get_coords()
|
1865
1887
|
if self.text_editor.open:
|
1866
1888
|
text_editor_h = self.text_editor.window.winfo_height()
|
1867
1889
|
win_h, anchor = self.get_dropdown_height_anchor(r, text_editor_h)
|
1868
1890
|
else:
|
1869
|
-
text_editor_h = self.MT.row_positions[r + 1] - self.MT.row_positions[r]
|
1891
|
+
text_editor_h = self.MT.row_positions[r + 1] - self.MT.row_positions[r] + 1
|
1870
1892
|
anchor = self.itemcget(self.dropdown.canvas_id, "anchor")
|
1871
1893
|
# win_h = 0
|
1894
|
+
self.dropdown.window.config(width=self.current_width + 1)
|
1872
1895
|
if anchor == "nw":
|
1873
1896
|
self.coords(
|
1874
1897
|
self.dropdown.canvas_id,
|
@@ -1886,6 +1909,8 @@ class RowIndex(tk.Canvas):
|
|
1886
1909
|
|
1887
1910
|
def hide_text_editor(self, reason: None | str = None) -> None:
|
1888
1911
|
if self.text_editor.open:
|
1912
|
+
for b in ("<Alt-Return>", "<Option-Return>", "<Tab>", "<Return>", "<FocusOut>", "<Escape>"):
|
1913
|
+
self.text_editor.tktext.unbind(b)
|
1889
1914
|
self.itemconfig(self.text_editor.canvas_id, state="hidden")
|
1890
1915
|
self.text_editor.open = False
|
1891
1916
|
if reason == "Escape":
|
@@ -1907,7 +1932,7 @@ class RowIndex(tk.Canvas):
|
|
1907
1932
|
if editor_info is not None and len(editor_info) >= 2 and editor_info[1] == "Escape":
|
1908
1933
|
self.hide_text_editor_and_dropdown()
|
1909
1934
|
return
|
1910
|
-
|
1935
|
+
text_editor_value = self.text_editor.get()
|
1911
1936
|
r = editor_info[0]
|
1912
1937
|
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1913
1938
|
event_data = event_dict(
|
@@ -1915,7 +1940,7 @@ class RowIndex(tk.Canvas):
|
|
1915
1940
|
sheet=self.PAR.name,
|
1916
1941
|
cells_index={datarn: self.get_cell_data(datarn)},
|
1917
1942
|
key=editor_info[1] if len(editor_info) >= 2 else "FocusOut",
|
1918
|
-
value=
|
1943
|
+
value=text_editor_value,
|
1919
1944
|
loc=r,
|
1920
1945
|
boxes=self.MT.get_boxes(),
|
1921
1946
|
selected=self.MT.selected,
|
@@ -1928,11 +1953,11 @@ class RowIndex(tk.Canvas):
|
|
1928
1953
|
check_input_valid=False,
|
1929
1954
|
)
|
1930
1955
|
if self.MT.edit_validation_func:
|
1931
|
-
|
1932
|
-
if
|
1933
|
-
edited = set_data(value=
|
1934
|
-
elif self.input_valid_for_cell(datarn,
|
1935
|
-
edited = set_data(value=
|
1956
|
+
text_editor_value = self.MT.edit_validation_func(event_data)
|
1957
|
+
if text_editor_value is not None and self.input_valid_for_cell(datarn, text_editor_value):
|
1958
|
+
edited = set_data(value=text_editor_value)
|
1959
|
+
elif self.input_valid_for_cell(datarn, text_editor_value):
|
1960
|
+
edited = set_data(value=text_editor_value)
|
1936
1961
|
if edited:
|
1937
1962
|
try_binding(self.extra_end_edit_cell_func, event_data)
|
1938
1963
|
self.MT.recreate_all_selection_boxes()
|
@@ -1956,15 +1981,22 @@ class RowIndex(tk.Canvas):
|
|
1956
1981
|
break
|
1957
1982
|
if win_h > 500:
|
1958
1983
|
win_h = 500
|
1959
|
-
space_bot = self.MT.get_space_bot(
|
1984
|
+
space_bot = self.MT.get_space_bot(r, text_editor_h)
|
1985
|
+
space_top = int(self.MT.row_positions[r])
|
1986
|
+
anchor = "nw"
|
1960
1987
|
win_h2 = int(win_h)
|
1961
1988
|
if win_h > space_bot:
|
1962
|
-
|
1989
|
+
if space_bot >= space_top:
|
1990
|
+
anchor = "nw"
|
1991
|
+
win_h = space_bot - 1
|
1992
|
+
elif space_top > space_bot:
|
1993
|
+
anchor = "sw"
|
1994
|
+
win_h = space_top - 1
|
1963
1995
|
if win_h < self.MT.index_txt_height + 5:
|
1964
1996
|
win_h = self.MT.index_txt_height + 5
|
1965
1997
|
elif win_h > win_h2:
|
1966
1998
|
win_h = win_h2
|
1967
|
-
return win_h,
|
1999
|
+
return win_h, anchor
|
1968
2000
|
|
1969
2001
|
def dropdown_text_editor_modified(
|
1970
2002
|
self,
|
@@ -1977,17 +2009,21 @@ class RowIndex(tk.Canvas):
|
|
1977
2009
|
dd_window.search_and_see(event)
|
1978
2010
|
|
1979
2011
|
# r is displayed row
|
1980
|
-
def open_dropdown_window(self, r,
|
2012
|
+
def open_dropdown_window(self, r, event: object = None):
|
1981
2013
|
self.hide_text_editor("Escape")
|
1982
|
-
|
1983
|
-
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1984
|
-
kwargs = self.get_cell_kwargs(datarn, key="dropdown")
|
2014
|
+
kwargs = self.get_cell_kwargs(self.MT.datarn(r), key="dropdown")
|
1985
2015
|
if kwargs["state"] == "normal":
|
1986
2016
|
if not self.open_text_editor(event=event, r=r, dropdown=True):
|
1987
2017
|
return
|
1988
2018
|
win_h, anchor = self.get_dropdown_height_anchor(r)
|
1989
|
-
win_w = self.current_width
|
1990
|
-
|
2019
|
+
win_w = self.current_width + 1
|
2020
|
+
if anchor == "nw":
|
2021
|
+
if kwargs["state"] == "normal":
|
2022
|
+
ypos = self.MT.row_positions[r] + self.text_editor.window.winfo_height() - 1
|
2023
|
+
else:
|
2024
|
+
ypos = self.MT.row_positions[r + 1]
|
2025
|
+
else:
|
2026
|
+
ypos = self.MT.row_positions[r]
|
1991
2027
|
reset_kwargs = {
|
1992
2028
|
"r": r,
|
1993
2029
|
"c": 0,
|
@@ -2001,7 +2037,7 @@ class RowIndex(tk.Canvas):
|
|
2001
2037
|
}
|
2002
2038
|
if self.dropdown.window:
|
2003
2039
|
self.dropdown.window.reset(**reset_kwargs)
|
2004
|
-
self.itemconfig(self.dropdown.canvas_id, state="normal")
|
2040
|
+
self.itemconfig(self.dropdown.canvas_id, state="normal", anchor=anchor)
|
2005
2041
|
self.coords(self.dropdown.canvas_id, 0, ypos)
|
2006
2042
|
else:
|
2007
2043
|
self.dropdown.window = self.PAR.dropdown_class(
|
@@ -2108,6 +2144,7 @@ class RowIndex(tk.Canvas):
|
|
2108
2144
|
|
2109
2145
|
def hide_dropdown_window(self) -> None:
|
2110
2146
|
if self.dropdown.open:
|
2147
|
+
self.dropdown.window.unbind("<FocusOut>")
|
2111
2148
|
self.itemconfig(self.dropdown.canvas_id, state="hidden")
|
2112
2149
|
self.dropdown.open = False
|
2113
2150
|
|
tksheet/sheet.py
CHANGED
@@ -171,6 +171,9 @@ class Sheet(tk.Frame):
|
|
171
171
|
display_selected_fg_over_highlights: bool = False,
|
172
172
|
show_selected_cells_border: bool = True,
|
173
173
|
treeview: bool = False,
|
174
|
+
treeview_indent: str | int = "3",
|
175
|
+
rounded_boxes: bool = True,
|
176
|
+
alternate_color: str = "",
|
174
177
|
# colors
|
175
178
|
outline_thickness: int = 0,
|
176
179
|
outline_color: str = theme_light_blue["outline_color"],
|
@@ -1092,6 +1095,14 @@ class Sheet(tk.Frame):
|
|
1092
1095
|
self.TL.focus_set()
|
1093
1096
|
return self
|
1094
1097
|
|
1098
|
+
def zoom_in(self) -> Sheet:
|
1099
|
+
self.MT.zoom_in()
|
1100
|
+
return self
|
1101
|
+
|
1102
|
+
def zoom_out(self) -> Sheet:
|
1103
|
+
self.MT.zoom_out()
|
1104
|
+
return self
|
1105
|
+
|
1095
1106
|
@property
|
1096
1107
|
def event(self) -> EventDataDict:
|
1097
1108
|
return self.last_event_data
|
@@ -3174,6 +3185,16 @@ class Sheet(tk.Frame):
|
|
3174
3185
|
self.set_refresh_timer(redraw)
|
3175
3186
|
return self
|
3176
3187
|
|
3188
|
+
def deselect_any(
|
3189
|
+
self,
|
3190
|
+
rows: Iterator[int] | int | None,
|
3191
|
+
columns: Iterator[int] | int | None,
|
3192
|
+
redraw: bool = True,
|
3193
|
+
) -> Sheet:
|
3194
|
+
self.MT.deselect_any(rows=rows, columns=columns, redraw=False)
|
3195
|
+
self.set_refresh_timer(redraw)
|
3196
|
+
return self
|
3197
|
+
|
3177
3198
|
# Row Heights and Column Widths
|
3178
3199
|
|
3179
3200
|
def default_column_width(self, width: int | None = None) -> int:
|
@@ -4538,6 +4559,7 @@ class Sheet(tk.Frame):
|
|
4538
4559
|
text: str | None = None,
|
4539
4560
|
values: list | None = None,
|
4540
4561
|
open_: bool | None = None,
|
4562
|
+
redraw: bool = True,
|
4541
4563
|
) -> DotDict | Sheet:
|
4542
4564
|
"""
|
4543
4565
|
Modify options for item
|
@@ -4580,7 +4602,7 @@ class Sheet(tk.Frame):
|
|
4580
4602
|
else:
|
4581
4603
|
self.RI.tree_open_ids.discard(item)
|
4582
4604
|
get = not (isinstance(iid, str) or isinstance(text, str) or isinstance(values, list) or isinstance(open_, bool))
|
4583
|
-
self.set_refresh_timer(redraw=not get)
|
4605
|
+
self.set_refresh_timer(redraw=not get or redraw)
|
4584
4606
|
if get:
|
4585
4607
|
return DotDict(
|
4586
4608
|
text=self.RI.tree[item].text,
|
@@ -4596,10 +4618,11 @@ class Sheet(tk.Frame):
|
|
4596
4618
|
raise ValueError(f"item '{item.lower()}' does not exist.")
|
4597
4619
|
|
4598
4620
|
def rowitem(self, row: int, data_index: bool = False) -> str | None:
|
4599
|
-
if
|
4600
|
-
|
4601
|
-
|
4602
|
-
|
4621
|
+
if isinstance(row, int):
|
4622
|
+
if not data_index:
|
4623
|
+
row = self.data_r(row)
|
4624
|
+
if len(self.MT._row_index) > row:
|
4625
|
+
return self.MT._row_index[row].iid
|
4603
4626
|
return None
|
4604
4627
|
|
4605
4628
|
def get_children(self, item: None | str = None) -> Generator[str]:
|
@@ -4640,67 +4663,23 @@ class Sheet(tk.Frame):
|
|
4640
4663
|
self.set_refresh_timer(True)
|
4641
4664
|
return self
|
4642
4665
|
|
4643
|
-
def set_children(self,
|
4666
|
+
def set_children(self, parent: str, *newchildren) -> Sheet:
|
4644
4667
|
"""
|
4645
|
-
Moves everything in '*newchildren' under '
|
4668
|
+
Moves everything in '*newchildren' under 'parent'
|
4646
4669
|
"""
|
4647
|
-
|
4648
|
-
|
4649
|
-
mapping = {}
|
4650
|
-
to_show = []
|
4651
|
-
if item:
|
4652
|
-
new_parent = self.RI.tree[item]
|
4653
|
-
if new_parent.children:
|
4654
|
-
ctr = self.RI.tree_rns[new_parent.children[-1].iid] + 1
|
4655
|
-
else:
|
4656
|
-
ctr = self.RI.tree_rns[new_parent.iid] + 1
|
4657
|
-
for cid in unpack(newchildren):
|
4658
|
-
if self.RI.pid_causes_recursive_loop(cid, item):
|
4659
|
-
raise ValueError(f"iid '{cid}' causes a recursive loop with parent '{item}'.")
|
4660
|
-
cid_node = self.RI.tree[cid]
|
4661
|
-
mapping[self.RI.tree_rns[cid]] = ctr
|
4662
|
-
if item in self.RI.tree_open_ids and self.item_displayed(item):
|
4663
|
-
to_show.append(ctr)
|
4664
|
-
ctr += 1
|
4665
|
-
for did in self.RI.get_iid_descendants(cid):
|
4666
|
-
mapping[self.RI.tree_rns[did]] = ctr
|
4667
|
-
if to_show and self.RI.ancestors_all_open(did, self.RI.tree[cid].parent):
|
4668
|
-
to_show.append(ctr)
|
4669
|
-
ctr += 1
|
4670
|
-
self.RI.remove_node_from_parents_children(cid_node)
|
4671
|
-
cid_node.parent = new_parent
|
4672
|
-
new_parent.children.append(cid_node)
|
4673
|
-
else:
|
4674
|
-
ctr = (
|
4675
|
-
len(self.MT._row_index)
|
4676
|
-
- len(newchildren)
|
4677
|
-
- sum(1 for cid in unpack(newchildren) for _ in self.RI.get_iid_descendants(cid))
|
4678
|
-
)
|
4679
|
-
for cid in unpack(newchildren):
|
4680
|
-
cid_node = self.RI.tree[cid]
|
4681
|
-
mapping[self.RI.tree_rns[cid]] = ctr
|
4682
|
-
to_show.append(ctr)
|
4683
|
-
ctr += 1
|
4684
|
-
for did in self.RI.get_iid_descendants(cid):
|
4685
|
-
mapping[self.RI.tree_rns[did]] = ctr
|
4686
|
-
if self.RI.ancestors_all_open(did, cid_node.parent):
|
4687
|
-
to_show.append(ctr)
|
4688
|
-
ctr += 1
|
4689
|
-
self.RI.remove_node_from_parents_children(cid_node)
|
4690
|
-
self.RI.tree[cid].parent = ""
|
4691
|
-
self.mapping_move_rows(
|
4692
|
-
data_new_idxs=mapping,
|
4693
|
-
data_indexes=True,
|
4694
|
-
create_selections=False,
|
4695
|
-
redraw=False,
|
4696
|
-
)
|
4697
|
-
if item and (item not in self.RI.tree_open_ids or not self.item_displayed(item)):
|
4698
|
-
self.hide_rows(set(mapping.values()), data_indexes=True)
|
4699
|
-
self.show_rows(to_show)
|
4700
|
-
self.set_refresh_timer(True)
|
4670
|
+
for iid in unpack(newchildren):
|
4671
|
+
self.move(iid, parent)
|
4701
4672
|
return self
|
4702
4673
|
|
4703
|
-
def
|
4674
|
+
def find_rn_at_top_index(self, index: int) -> int:
|
4675
|
+
wo_par = 0
|
4676
|
+
for rn, n in enumerate(self.MT._row_index):
|
4677
|
+
if not n.parent:
|
4678
|
+
if wo_par == index:
|
4679
|
+
return rn
|
4680
|
+
wo_par += 1
|
4681
|
+
|
4682
|
+
def move(self, item: str, parent: str, index: int | None = None) -> Sheet:
|
4704
4683
|
"""
|
4705
4684
|
Moves item to be under parent as child at index
|
4706
4685
|
'parent' can be empty string which will make item a top node
|
@@ -4717,35 +4696,49 @@ class Sheet(tk.Frame):
|
|
4717
4696
|
raise ValueError(f"iid '{item}' causes a recursive loop with parent '{parent}'.")
|
4718
4697
|
parent_node = self.RI.tree[parent]
|
4719
4698
|
if parent_node.children:
|
4720
|
-
if len(parent_node.children)
|
4721
|
-
index = len(parent_node.children)
|
4722
|
-
|
4699
|
+
if index is None or index >= len(parent_node.children):
|
4700
|
+
index = len(parent_node.children) - 1
|
4701
|
+
item_r = self.RI.tree_rns[item]
|
4702
|
+
new_r = self.RI.tree_rns[parent_node.children[index].iid]
|
4703
|
+
if item_node not in parent_node.children:
|
4704
|
+
new_r += 1
|
4705
|
+
new_r_desc = sum(1 for _ in self.RI.get_iid_descendants(parent_node.children[index].iid))
|
4706
|
+
item_desc = sum(1 for _ in self.RI.get_iid_descendants(item))
|
4707
|
+
if item_r < new_r:
|
4708
|
+
r_ctr = new_r + new_r_desc - item_desc
|
4709
|
+
else:
|
4710
|
+
r_ctr = new_r
|
4723
4711
|
else:
|
4724
|
-
|
4725
|
-
mapping[
|
4712
|
+
r_ctr = self.RI.tree_rns[parent_node.iid] + 1
|
4713
|
+
mapping[item_r] = r_ctr
|
4726
4714
|
if parent in self.RI.tree_open_ids and self.item_displayed(parent):
|
4727
|
-
to_show.append(
|
4728
|
-
|
4715
|
+
to_show.append(r_ctr)
|
4716
|
+
r_ctr += 1
|
4729
4717
|
for did in self.RI.get_iid_descendants(item):
|
4730
|
-
mapping[self.RI.tree_rns[did]] =
|
4718
|
+
mapping[self.RI.tree_rns[did]] = r_ctr
|
4731
4719
|
if to_show and self.RI.ancestors_all_open(did, item_node.parent):
|
4732
|
-
to_show.append(
|
4733
|
-
|
4720
|
+
to_show.append(r_ctr)
|
4721
|
+
r_ctr += 1
|
4734
4722
|
self.RI.remove_node_from_parents_children(item_node)
|
4735
4723
|
item_node.parent = parent_node
|
4736
4724
|
parent_node.children.append(item_node)
|
4737
4725
|
else:
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4726
|
+
new_r = self.find_rn_at_top_index((sum(1 for _ in self.get_children("")) - 1) if index is None else index)
|
4727
|
+
item_r = self.RI.tree_rns[item]
|
4728
|
+
if item_r < new_r:
|
4729
|
+
par_desc = sum(1 for _ in self.RI.get_iid_descendants(self.rowitem(new_r, data_index=True)))
|
4730
|
+
item_desc = sum(1 for _ in self.RI.get_iid_descendants(item))
|
4731
|
+
r_ctr = new_r + par_desc - item_desc
|
4732
|
+
else:
|
4733
|
+
r_ctr = new_r
|
4734
|
+
mapping[item_r] = r_ctr
|
4735
|
+
to_show.append(r_ctr)
|
4736
|
+
r_ctr += 1
|
4744
4737
|
for did in self.RI.get_iid_descendants(item):
|
4745
|
-
mapping[self.RI.tree_rns[did]] =
|
4738
|
+
mapping[self.RI.tree_rns[did]] = r_ctr
|
4746
4739
|
if to_show and self.RI.ancestors_all_open(did, item_node.parent):
|
4747
|
-
to_show.append(
|
4748
|
-
|
4740
|
+
to_show.append(r_ctr)
|
4741
|
+
r_ctr += 1
|
4749
4742
|
self.RI.remove_node_from_parents_children(item_node)
|
4750
4743
|
self.RI.tree[item].parent = ""
|
4751
4744
|
self.mapping_move_rows(
|
tksheet/sheet_options.py
CHANGED
@@ -234,6 +234,8 @@ def new_sheet_options() -> DotDict:
|
|
234
234
|
"display_selected_fg_over_highlights": False,
|
235
235
|
"show_selected_cells_border": True,
|
236
236
|
"treeview": False,
|
237
|
-
"treeview_indent": "
|
237
|
+
"treeview_indent": "3",
|
238
|
+
"rounded_boxes": True,
|
239
|
+
"alternate_color": "",
|
238
240
|
}
|
239
241
|
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
tksheet/__init__.py,sha256=UgweIADXnlw1-KpD4Xr0sA_l6qAWTP3yzQ1Bo716Fkg,2010
|
2
|
+
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
+
tksheet/column_headers.py,sha256=dBEnPjbI6nqcS0OISWJ0tXBBxtGjB67OE8z2-Bx8X1U,99870
|
4
|
+
tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
|
5
|
+
tksheet/functions.py,sha256=dMJwG27Qo5WsfwzkL7A9X-PERGuGFhpQvP95BnlohJ8,39612
|
6
|
+
tksheet/listbox.py,sha256=BUHx-PsZL6yGMewxAaEZV_8mOXCVWenWqzHp3tasGvo,384
|
7
|
+
tksheet/main_table.py,sha256=ngwXVNqrtOZPtR-BqCuh7UVAubfB8v_JfdI2peJAzPM,323154
|
8
|
+
tksheet/other_classes.py,sha256=Hjr7c0kD2_880xjtGuFn9gQ-7ED5kSiNahniBeXcf84,13604
|
9
|
+
tksheet/row_index.py,sha256=NHFu5a35nPMuxajHhpS2RH8sOTYKKKb6WGO8zWofxqs,105354
|
10
|
+
tksheet/sheet.py,sha256=PbCa8RCiBYg3Zl_26j1aIKphGst84S2lGHKodnZ6Kk0,256166
|
11
|
+
tksheet/sheet_options.py,sha256=mh0rTvWrFvIKaiv88jtMZy0TSA8zTS1GXSe88u8_rzk,11978
|
12
|
+
tksheet/text_editor.py,sha256=81_IZKrTVa2KIx2cJ4n3cFvFMAwvbHIQYgqtyat-97I,6681
|
13
|
+
tksheet/themes.py,sha256=OwUe31NRbosjw3ZoZsMyB8lNVyYin9YcKLhCturi5q8,13398
|
14
|
+
tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
|
15
|
+
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
16
|
+
tksheet/vars.py,sha256=Iukk7-MMT9X7vv0m3nQPKzbp2Iw2Pg1wJEW7js919Mo,2092
|
17
|
+
tksheet-7.1.7.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
18
|
+
tksheet-7.1.7.dist-info/METADATA,sha256=w5PeLRxO5tOgSz577YZLks3-OtluVDYw6Kw--fixI8w,6013
|
19
|
+
tksheet-7.1.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
20
|
+
tksheet-7.1.7.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
21
|
+
tksheet-7.1.7.dist-info/RECORD,,
|
tksheet-7.1.5.dist-info/RECORD
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
tksheet/__init__.py,sha256=bzXUATwg31SEbu5F3bS-MFBDpi4MAuMZ0TPh49RAonU,1874
|
2
|
-
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
-
tksheet/column_headers.py,sha256=9LOi8-Xr7_h0UlF277VDVg_UWQ3UGVwD9fufwq3SbMU,99272
|
4
|
-
tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
|
5
|
-
tksheet/functions.py,sha256=PN2qanv32V4Hg221b-999fEH4yxYNoze925txUP5kA4,39245
|
6
|
-
tksheet/main_table.py,sha256=QHFqCkCWkiecHBjbiGBJSJ0SoMp2htXBCpkLIMQEeWI,318511
|
7
|
-
tksheet/other_classes.py,sha256=Hjr7c0kD2_880xjtGuFn9gQ-7ED5kSiNahniBeXcf84,13604
|
8
|
-
tksheet/row_index.py,sha256=ZPBiKNB5NghU_Q-LEqWrC9-VqaVYj__DodenDSR_oeA,103990
|
9
|
-
tksheet/sheet.py,sha256=ho4dGIco8GTCJluFZcJhOJNgnJTA_S_dMm-xU4cJPGo,256866
|
10
|
-
tksheet/sheet_options.py,sha256=Vcy4RxTKvf2HM-Yc53ex0lpBe6ATXc_pdx4oLhfjDgU,11906
|
11
|
-
tksheet/text_editor.py,sha256=81_IZKrTVa2KIx2cJ4n3cFvFMAwvbHIQYgqtyat-97I,6681
|
12
|
-
tksheet/themes.py,sha256=OwUe31NRbosjw3ZoZsMyB8lNVyYin9YcKLhCturi5q8,13398
|
13
|
-
tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
|
14
|
-
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
15
|
-
tksheet/vars.py,sha256=Iukk7-MMT9X7vv0m3nQPKzbp2Iw2Pg1wJEW7js919Mo,2092
|
16
|
-
tksheet-7.1.5.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
17
|
-
tksheet-7.1.5.dist-info/METADATA,sha256=WBm8p-qBsL207lJ6_tznMJE9Vo62iKaZmj-nmyj-UbE,6013
|
18
|
-
tksheet-7.1.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
19
|
-
tksheet-7.1.5.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
20
|
-
tksheet-7.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|