tksheet 7.1.4__py3-none-any.whl → 7.1.6__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 +1 -1
- tksheet/column_headers.py +91 -73
- tksheet/functions.py +39 -11
- tksheet/main_table.py +240 -163
- tksheet/row_index.py +100 -79
- tksheet/sheet.py +101 -73
- tksheet/text_editor.py +8 -6
- {tksheet-7.1.4.dist-info → tksheet-7.1.6.dist-info}/METADATA +1 -1
- tksheet-7.1.6.dist-info/RECORD +20 -0
- tksheet-7.1.4.dist-info/RECORD +0 -20
- {tksheet-7.1.4.dist-info → tksheet-7.1.6.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.1.4.dist-info → tksheet-7.1.6.dist-info}/WHEEL +0 -0
- {tksheet-7.1.4.dist-info → tksheet-7.1.6.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,
|
@@ -266,7 +267,9 @@ class RowIndex(tk.Canvas):
|
|
266
267
|
if self.MT.selected and self.MT.selected.type_ == "rows":
|
267
268
|
r_to_sel, c_to_sel = self.MT.selected.row, self.MT.selected.column
|
268
269
|
self.MT.deselect("all", redraw=False)
|
269
|
-
self.being_drawn_item = self.MT.create_selection_box(
|
270
|
+
self.being_drawn_item = self.MT.create_selection_box(
|
271
|
+
*self.get_shift_select_box(r, r_to_sel), "rows"
|
272
|
+
)
|
270
273
|
self.MT.set_currently_selected(r_to_sel, c_to_sel, self.being_drawn_item)
|
271
274
|
else:
|
272
275
|
self.being_drawn_item = self.select_row(r, run_binding_func=False)
|
@@ -864,6 +867,8 @@ class RowIndex(tk.Canvas):
|
|
864
867
|
):
|
865
868
|
self.open_cell(event)
|
866
869
|
elif (iid := self.event_over_tree_arrow(r, canvasy, event.x)) is not None:
|
870
|
+
if self.MT.selection_boxes:
|
871
|
+
self.select_row(r, redraw=False)
|
867
872
|
self.PAR.item(iid, open_=iid not in self.tree_open_ids)
|
868
873
|
else:
|
869
874
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
@@ -1012,11 +1017,10 @@ class RowIndex(tk.Canvas):
|
|
1012
1017
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
1013
1018
|
start_col, end_col = self.MT.get_visible_columns(x1, x2)
|
1014
1019
|
else:
|
1015
|
-
|
1016
|
-
0,
|
1017
|
-
|
1018
|
-
|
1019
|
-
iterable = range(start_col, end_col)
|
1020
|
+
if not self.MT.data or datarn >= len(self.MT.data):
|
1021
|
+
iterable = range(0, 0)
|
1022
|
+
else:
|
1023
|
+
iterable = range(0, len(self.MT.data[datarn]))
|
1020
1024
|
else:
|
1021
1025
|
if displayed_only:
|
1022
1026
|
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
@@ -1710,8 +1714,7 @@ class RowIndex(tk.Canvas):
|
|
1710
1714
|
extra_func_key = "Return"
|
1711
1715
|
elif hasattr(event, "keysym") and event.keysym == "F2":
|
1712
1716
|
extra_func_key = "F2"
|
1713
|
-
|
1714
|
-
text = self.get_cell_data(datarn, none_to_empty_str=True, redirect_int=True)
|
1717
|
+
text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
|
1715
1718
|
elif event is not None and (
|
1716
1719
|
(hasattr(event, "keysym") and event.keysym == "BackSpace") or event.keycode in (8, 855638143)
|
1717
1720
|
):
|
@@ -1756,12 +1759,11 @@ class RowIndex(tk.Canvas):
|
|
1756
1759
|
if not self.MT.see(r=r, c=0, keep_yscroll=True, check_cell_visibility=True):
|
1757
1760
|
self.MT.refresh()
|
1758
1761
|
x = 0
|
1759
|
-
y = self.MT.row_positions[r]
|
1762
|
+
y = self.MT.row_positions[r]
|
1760
1763
|
w = self.current_width + 1
|
1761
|
-
h = self.MT.row_positions[r + 1] - y
|
1762
|
-
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1764
|
+
h = self.MT.row_positions[r + 1] - y + 1
|
1763
1765
|
if text is None:
|
1764
|
-
text = self.get_cell_data(datarn, none_to_empty_str=True, redirect_int=True)
|
1766
|
+
text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
|
1765
1767
|
bg, fg = self.PAR.ops.index_bg, self.PAR.ops.index_fg
|
1766
1768
|
kwargs = {
|
1767
1769
|
"menu_kwargs": DotDict(
|
@@ -1774,12 +1776,12 @@ class RowIndex(tk.Canvas):
|
|
1774
1776
|
}
|
1775
1777
|
),
|
1776
1778
|
"sheet_ops": self.PAR.ops,
|
1777
|
-
"border_color": self.PAR.ops.
|
1779
|
+
"border_color": self.PAR.ops.index_selected_rows_bg,
|
1778
1780
|
"text": text,
|
1779
1781
|
"state": state,
|
1780
1782
|
"width": w,
|
1781
1783
|
"height": h,
|
1782
|
-
"show_border":
|
1784
|
+
"show_border": True,
|
1783
1785
|
"bg": bg,
|
1784
1786
|
"fg": fg,
|
1785
1787
|
"align": self.get_cell_align(r),
|
@@ -1809,61 +1811,70 @@ class RowIndex(tk.Canvas):
|
|
1809
1811
|
return True
|
1810
1812
|
|
1811
1813
|
def text_editor_newline_binding(self, r=0, c=0, event: object = None, check_lines=True):
|
1812
|
-
if self.height_resizing_enabled:
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
self.
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
self.
|
1814
|
+
if not self.height_resizing_enabled:
|
1815
|
+
return
|
1816
|
+
curr_height = self.text_editor.window.winfo_height()
|
1817
|
+
if curr_height < self.MT.min_row_height:
|
1818
|
+
return
|
1819
|
+
if (
|
1820
|
+
not check_lines
|
1821
|
+
or self.MT.get_lines_cell_height(
|
1822
|
+
self.text_editor.window.get_num_lines() + 1,
|
1823
|
+
font=self.text_editor.tktext.cget("font"),
|
1824
|
+
)
|
1825
|
+
> curr_height
|
1826
|
+
):
|
1827
|
+
new_height = curr_height + self.MT.index_xtra_lines_increment
|
1828
|
+
space_bot = self.MT.get_space_bot(r)
|
1829
|
+
if new_height > space_bot:
|
1830
|
+
new_height = space_bot
|
1831
|
+
if new_height != curr_height:
|
1832
|
+
self.set_row_height(r, new_height)
|
1833
|
+
self.MT.refresh()
|
1834
|
+
self.text_editor.window.config(height=new_height)
|
1835
|
+
self.coords(self.text_editor.canvas_id, 0, self.MT.row_positions[r] + 1)
|
1836
|
+
if self.dropdown.open and self.dropdown.get_coords() == r:
|
1837
|
+
text_editor_h = self.text_editor.window.winfo_height()
|
1838
|
+
win_h, anchor = self.get_dropdown_height_anchor(r, text_editor_h)
|
1839
|
+
if anchor == "nw":
|
1840
|
+
self.coords(
|
1841
|
+
self.dropdown.canvas_id,
|
1842
|
+
self.MT.col_positions[c],
|
1843
|
+
self.MT.row_positions[r] + text_editor_h - 1,
|
1844
|
+
)
|
1845
|
+
self.itemconfig(self.dropdown.canvas_id, anchor=anchor, height=win_h)
|
1846
|
+
elif anchor == "sw":
|
1847
|
+
self.coords(
|
1848
|
+
self.dropdown.canvas_id,
|
1849
|
+
self.MT.col_positions[c],
|
1850
|
+
self.MT.row_positions[r],
|
1851
|
+
)
|
1852
|
+
self.itemconfig(self.dropdown.canvas_id, anchor=anchor, height=win_h)
|
1848
1853
|
|
1849
|
-
def refresh_open_window_positions(self):
|
1854
|
+
def refresh_open_window_positions(self, zoom: Literal["in", "out"]):
|
1850
1855
|
if self.text_editor.open:
|
1851
1856
|
r = self.text_editor.row
|
1852
1857
|
self.text_editor.window.config(height=self.MT.row_positions[r + 1] - self.MT.row_positions[r])
|
1858
|
+
self.text_editor.tktext.config(font=self.PAR.ops.index_font)
|
1853
1859
|
self.coords(
|
1854
1860
|
self.text_editor.canvas_id,
|
1855
1861
|
0,
|
1856
1862
|
self.MT.row_positions[r],
|
1857
1863
|
)
|
1858
1864
|
if self.dropdown.open:
|
1865
|
+
if zoom == "in":
|
1866
|
+
self.dropdown.window.zoom_in()
|
1867
|
+
elif zoom == "out":
|
1868
|
+
self.dropdown.window.zoom_out()
|
1859
1869
|
r = self.dropdown.get_coords()
|
1860
1870
|
if self.text_editor.open:
|
1861
1871
|
text_editor_h = self.text_editor.window.winfo_height()
|
1862
1872
|
win_h, anchor = self.get_dropdown_height_anchor(r, text_editor_h)
|
1863
1873
|
else:
|
1864
|
-
text_editor_h = self.MT.row_positions[r + 1] - self.MT.row_positions[r]
|
1874
|
+
text_editor_h = self.MT.row_positions[r + 1] - self.MT.row_positions[r] + 1
|
1865
1875
|
anchor = self.itemcget(self.dropdown.canvas_id, "anchor")
|
1866
1876
|
# win_h = 0
|
1877
|
+
self.dropdown.window.config(width=self.current_width + 1)
|
1867
1878
|
if anchor == "nw":
|
1868
1879
|
self.coords(
|
1869
1880
|
self.dropdown.canvas_id,
|
@@ -1951,15 +1962,22 @@ class RowIndex(tk.Canvas):
|
|
1951
1962
|
break
|
1952
1963
|
if win_h > 500:
|
1953
1964
|
win_h = 500
|
1954
|
-
space_bot = self.MT.get_space_bot(
|
1965
|
+
space_bot = self.MT.get_space_bot(r, text_editor_h)
|
1966
|
+
space_top = int(self.MT.row_positions[r])
|
1967
|
+
anchor = "nw"
|
1955
1968
|
win_h2 = int(win_h)
|
1956
1969
|
if win_h > space_bot:
|
1957
|
-
|
1970
|
+
if space_bot >= space_top:
|
1971
|
+
anchor = "nw"
|
1972
|
+
win_h = space_bot - 1
|
1973
|
+
elif space_top > space_bot:
|
1974
|
+
anchor = "sw"
|
1975
|
+
win_h = space_top - 1
|
1958
1976
|
if win_h < self.MT.index_txt_height + 5:
|
1959
1977
|
win_h = self.MT.index_txt_height + 5
|
1960
1978
|
elif win_h > win_h2:
|
1961
1979
|
win_h = win_h2
|
1962
|
-
return win_h,
|
1980
|
+
return win_h, anchor
|
1963
1981
|
|
1964
1982
|
def dropdown_text_editor_modified(
|
1965
1983
|
self,
|
@@ -1972,42 +1990,45 @@ class RowIndex(tk.Canvas):
|
|
1972
1990
|
dd_window.search_and_see(event)
|
1973
1991
|
|
1974
1992
|
# r is displayed row
|
1975
|
-
def open_dropdown_window(self, r,
|
1993
|
+
def open_dropdown_window(self, r, event: object = None):
|
1976
1994
|
self.hide_text_editor("Escape")
|
1977
|
-
|
1978
|
-
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1979
|
-
kwargs = self.get_cell_kwargs(datarn, key="dropdown")
|
1995
|
+
kwargs = self.get_cell_kwargs(self.MT.datarn(r), key="dropdown")
|
1980
1996
|
if kwargs["state"] == "normal":
|
1981
1997
|
if not self.open_text_editor(event=event, r=r, dropdown=True):
|
1982
1998
|
return
|
1983
1999
|
win_h, anchor = self.get_dropdown_height_anchor(r)
|
1984
|
-
|
1985
|
-
if
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
2000
|
+
win_w = self.current_width + 1
|
2001
|
+
if anchor == "nw":
|
2002
|
+
if kwargs["state"] == "normal":
|
2003
|
+
ypos = self.MT.row_positions[r] + self.text_editor.window.winfo_height() - 1
|
2004
|
+
else:
|
2005
|
+
ypos = self.MT.row_positions[r + 1]
|
2006
|
+
else:
|
2007
|
+
ypos = self.MT.row_positions[r]
|
2008
|
+
reset_kwargs = {
|
2009
|
+
"r": r,
|
2010
|
+
"c": 0,
|
2011
|
+
"width": win_w,
|
2012
|
+
"height": win_h,
|
2013
|
+
"font": self.PAR.ops.index_font,
|
2014
|
+
"ops": self.PAR.ops,
|
2015
|
+
"outline_color": self.PAR.ops.popup_menu_fg,
|
2016
|
+
"align": self.get_cell_align(r),
|
2017
|
+
"values": kwargs["values"],
|
2018
|
+
}
|
2019
|
+
if self.dropdown.window:
|
2020
|
+
self.dropdown.window.reset(**reset_kwargs)
|
2021
|
+
self.itemconfig(self.dropdown.canvas_id, state="normal", anchor=anchor)
|
1993
2022
|
self.coords(self.dropdown.canvas_id, 0, ypos)
|
1994
2023
|
else:
|
1995
2024
|
self.dropdown.window = self.PAR.dropdown_class(
|
1996
|
-
self.
|
1997
|
-
|
1998
|
-
|
1999
|
-
width=self.current_width,
|
2000
|
-
height=win_h,
|
2001
|
-
font=self.PAR.ops.index_font,
|
2002
|
-
ops=self.PAR.ops,
|
2003
|
-
outline_color=self.PAR.ops.popup_menu_fg,
|
2004
|
-
values=kwargs["values"],
|
2025
|
+
self.winfo_toplevel(),
|
2026
|
+
**reset_kwargs,
|
2027
|
+
single_index="r",
|
2005
2028
|
close_dropdown_window=self.close_dropdown_window,
|
2006
2029
|
search_function=kwargs["search_function"],
|
2007
2030
|
arrowkey_RIGHT=self.MT.arrowkey_RIGHT,
|
2008
2031
|
arrowkey_LEFT=self.MT.arrowkey_LEFT,
|
2009
|
-
align="w",
|
2010
|
-
single_index="r",
|
2011
2032
|
)
|
2012
2033
|
self.dropdown.canvas_id = self.create_window(
|
2013
2034
|
(0, ypos),
|