tksheet 7.4.12__tar.gz → 7.4.13__tar.gz

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.
Files changed (26) hide show
  1. {tksheet-7.4.12/tksheet.egg-info → tksheet-7.4.13}/PKG-INFO +7 -7
  2. {tksheet-7.4.12 → tksheet-7.4.13}/README.md +6 -6
  3. {tksheet-7.4.12 → tksheet-7.4.13}/pyproject.toml +1 -1
  4. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/__init__.py +1 -1
  5. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/column_headers.py +18 -18
  6. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/functions.py +17 -5
  7. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/main_table.py +132 -101
  8. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/other_classes.py +1 -1
  9. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/row_index.py +150 -112
  10. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/sheet.py +16 -10
  11. {tksheet-7.4.12 → tksheet-7.4.13/tksheet.egg-info}/PKG-INFO +7 -7
  12. {tksheet-7.4.12 → tksheet-7.4.13}/LICENSE.txt +0 -0
  13. {tksheet-7.4.12 → tksheet-7.4.13}/setup.cfg +0 -0
  14. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/colors.py +0 -0
  15. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/constants.py +0 -0
  16. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/find_window.py +0 -0
  17. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/formatters.py +0 -0
  18. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/sheet_options.py +0 -0
  19. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/sorting.py +0 -0
  20. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/text_editor.py +0 -0
  21. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/themes.py +0 -0
  22. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/tksheet_types.py +0 -0
  23. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet/top_left_rectangle.py +0 -0
  24. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet.egg-info/SOURCES.txt +0 -0
  25. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet.egg-info/dependency_links.txt +0 -0
  26. {tksheet-7.4.12 → tksheet-7.4.13}/tksheet.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tksheet
3
- Version: 7.4.12
3
+ Version: 7.4.13
4
4
  Summary: Tkinter table / sheet and treeview widget
5
5
  Author-email: ragardner <github@ragardner.simplelogin.com>
6
6
  License: Copyright (c) 2019 ragardner and open source contributors
@@ -63,23 +63,23 @@ License-File: LICENSE.txt
63
63
  <tbody>
64
64
  <tr>
65
65
  <td style="color: LightCoral">Versions 6.x.x &#8594;</td>
66
- <td><a href="https://github.com/ragardner/tksheet/wiki/Version-6">Documentation</a></td>
66
+ <td><a href="https://github.com/ragardner/tksheet/wiki/Version-6" target="_blank">Documentation</a></td>
67
67
  </tr>
68
68
  <tr>
69
69
  <td style="color: lightgreen">Versions 7.x.x &#8594;</td>
70
- <td><a href="https://ragardner.github.io/tksheet/DOCUMENTATION.html">Documentation</a></td>
70
+ <td><a href="https://ragardner.github.io/tksheet/DOCUMENTATION.html" target="_blank">Documentation</a></td>
71
71
  </tr>
72
72
  <tr>
73
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/blob/master/docs/CHANGELOG.md">Changelog</a></td>
73
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/blob/master/docs/CHANGELOG.md" target="_blank">Changelog</a></td>
74
74
  </tr>
75
75
  <tr>
76
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#asking-questions">Questions</a></td>
76
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#asking-questions" target="_blank">Questions</a></td>
77
77
  </tr>
78
78
  <tr>
79
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#issues">Issues</a></td>
79
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#issues" target="_blank">Issues</a></td>
80
80
  </tr>
81
81
  <tr>
82
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#enhancements-or-suggestions">Suggestions and Contributors</a></td>
82
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#enhancements-or-suggestions" target="_blank">Suggestions and Contributors</a></td>
83
83
  </tr>
84
84
  </tbody>
85
85
  </table>
@@ -18,23 +18,23 @@
18
18
  <tbody>
19
19
  <tr>
20
20
  <td style="color: LightCoral">Versions 6.x.x &#8594;</td>
21
- <td><a href="https://github.com/ragardner/tksheet/wiki/Version-6">Documentation</a></td>
21
+ <td><a href="https://github.com/ragardner/tksheet/wiki/Version-6" target="_blank">Documentation</a></td>
22
22
  </tr>
23
23
  <tr>
24
24
  <td style="color: lightgreen">Versions 7.x.x &#8594;</td>
25
- <td><a href="https://ragardner.github.io/tksheet/DOCUMENTATION.html">Documentation</a></td>
25
+ <td><a href="https://ragardner.github.io/tksheet/DOCUMENTATION.html" target="_blank">Documentation</a></td>
26
26
  </tr>
27
27
  <tr>
28
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/blob/master/docs/CHANGELOG.md">Changelog</a></td>
28
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/blob/master/docs/CHANGELOG.md" target="_blank">Changelog</a></td>
29
29
  </tr>
30
30
  <tr>
31
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#asking-questions">Questions</a></td>
31
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#asking-questions" target="_blank">Questions</a></td>
32
32
  </tr>
33
33
  <tr>
34
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#issues">Issues</a></td>
34
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#issues" target="_blank">Issues</a></td>
35
35
  </tr>
36
36
  <tr>
37
- <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#enhancements-or-suggestions">Suggestions and Contributors</a></td>
37
+ <td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#enhancements-or-suggestions" target="_blank">Suggestions and Contributors</a></td>
38
38
  </tr>
39
39
  </tbody>
40
40
  </table>
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
  name = "tksheet"
7
7
  description = "Tkinter table / sheet and treeview widget"
8
8
  readme = "README.md"
9
- version = "7.4.12"
9
+ version = "7.4.13"
10
10
  authors = [{ name = "ragardner", email = "github@ragardner.simplelogin.com" }]
11
11
  requires-python = ">=3.8"
12
12
  license = {file = "LICENSE.txt"}
@@ -4,7 +4,7 @@
4
4
  tksheet - A Python tkinter table widget
5
5
  """
6
6
 
7
- __version__ = "7.4.12"
7
+ __version__ = "7.4.13"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
@@ -5,7 +5,7 @@ from collections import defaultdict
5
5
  from collections.abc import Callable, Hashable, Iterator, Sequence
6
6
  from functools import partial
7
7
  from itertools import cycle, islice, repeat
8
- from math import ceil, floor
8
+ from math import ceil
9
9
  from operator import itemgetter
10
10
  from typing import Any, Literal
11
11
 
@@ -741,7 +741,7 @@ class ColumnHeaders(tk.Canvas):
741
741
  if size < self.ops.min_column_width:
742
742
  new_col_pos = ceil(self.MT.col_positions[self.rsz_w - 1] + self.ops.min_column_width)
743
743
  elif size > self.ops.max_column_width:
744
- new_col_pos = floor(self.MT.col_positions[self.rsz_w - 1] + self.ops.max_column_width)
744
+ new_col_pos = int(self.MT.col_positions[self.rsz_w - 1] + self.ops.max_column_width)
745
745
  increment = new_col_pos - self.MT.col_positions[self.rsz_w]
746
746
  self.MT.col_positions[self.rsz_w + 1 :] = [
747
747
  e + increment for e in islice(self.MT.col_positions, self.rsz_w + 1, None)
@@ -1373,7 +1373,7 @@ class ColumnHeaders(tk.Canvas):
1373
1373
  if draw_arrow:
1374
1374
  mod = (self.MT.header_txt_height - 1) if self.MT.header_txt_height % 2 else self.MT.header_txt_height
1375
1375
  small_mod = int(mod / 5)
1376
- mid_y = floor(self.MT.min_header_height / 2)
1376
+ mid_y = int(self.MT.min_header_height / 2)
1377
1377
  if open_:
1378
1378
  # up arrow
1379
1379
  points = (
@@ -1552,13 +1552,13 @@ class ColumnHeaders(tk.Canvas):
1552
1552
  else:
1553
1553
  align = self.align
1554
1554
  if kwargs:
1555
- max_width = crightgridln - cleftgridln - txt_h - 2
1556
- if align.endswith("w"):
1555
+ max_width = crightgridln - cleftgridln - txt_h - 5
1556
+ if align[-1] == "w":
1557
1557
  draw_x = cleftgridln + 2
1558
- elif align.endswith("e"):
1558
+ elif align[-1] == "e":
1559
1559
  draw_x = crightgridln - 5 - txt_h
1560
- elif align.endswith("n"):
1561
- draw_x = cleftgridln + ceil((crightgridln - cleftgridln - txt_h) / 2)
1560
+ elif align[-1] == "n":
1561
+ draw_x = cleftgridln + (crightgridln - cleftgridln - txt_h) / 2
1562
1562
  self.redraw_dropdown(
1563
1563
  cleftgridln,
1564
1564
  0,
@@ -1573,18 +1573,18 @@ class ColumnHeaders(tk.Canvas):
1573
1573
  )
1574
1574
  else:
1575
1575
  max_width = crightgridln - cleftgridln - 2
1576
- if align.endswith("w"):
1576
+ if align[-1] == "w":
1577
1577
  draw_x = cleftgridln + 2
1578
- elif align.endswith("e"):
1578
+ elif align[-1] == "e":
1579
1579
  draw_x = crightgridln - 2
1580
- elif align.endswith("n"):
1581
- draw_x = cleftgridln + floor((crightgridln - cleftgridln) / 2)
1580
+ elif align[-1] == "n":
1581
+ draw_x = cleftgridln + (crightgridln - cleftgridln) / 2
1582
1582
  if (kwargs := self.get_cell_kwargs(datacn, key="checkbox")) and max_width > txt_h + 1:
1583
1583
  box_w = txt_h + 1
1584
- if align.endswith("w"):
1584
+ if align[-1] == "w":
1585
1585
  draw_x += box_w + 3
1586
- elif align.endswith("n"):
1587
- draw_x += ceil(box_w / 2) + 1
1586
+ elif align[-1] == "n":
1587
+ draw_x += box_w / 2 + 1
1588
1588
  max_width -= box_w + 4
1589
1589
  try:
1590
1590
  draw_check = (
@@ -1606,9 +1606,9 @@ class ColumnHeaders(tk.Canvas):
1606
1606
  )
1607
1607
  if (
1608
1608
  max_width < self.MT.header_txt_width
1609
- or (align.endswith("w") and draw_x > scrollpos_right)
1610
- or (align.endswith("e") and cleftgridln + 5 > scrollpos_right)
1611
- or (align.endswith("n") and cleftgridln + 5 > scrollpos_right)
1609
+ or (align[-1] == "w" and draw_x > scrollpos_right)
1610
+ or (align[-1] == "e" and cleftgridln + 5 > scrollpos_right)
1611
+ or (align[-1] == "n" and cleftgridln + 5 > scrollpos_right)
1612
1612
  ):
1613
1613
  continue
1614
1614
  text = self.cell_str(datacn, fix=False)
@@ -793,6 +793,11 @@ def move_elements_by_mapping_gen(
793
793
  return (seq[old_idxs[i]] if i in old_idxs else next(remaining_values) for i in range(len(seq)))
794
794
 
795
795
 
796
+ def move_fast(seq: list[Any], new_idxs: dict[int, int], old_idxs: dict[int, int]) -> list[Any]:
797
+ remaining_values = (e for i, e in enumerate(seq) if i not in new_idxs)
798
+ return [seq[old_idxs[i]] if i in old_idxs else next(remaining_values) for i in range(len(seq))]
799
+
800
+
796
801
  def move_elements_to(
797
802
  seq: list[Any],
798
803
  move_to: int,
@@ -819,10 +824,17 @@ def get_new_indexes(
819
824
  returns {old idx: new idx, ...}
820
825
  """
821
826
  offset = sum(1 for i in to_move if i < move_to)
822
- new_idxs = dict(zip(to_move, range(move_to - offset, move_to - offset + len(to_move))))
823
- if get_inverse:
824
- return new_idxs, dict(zip(new_idxs.values(), new_idxs))
825
- return new_idxs
827
+ correct_move_to = move_to - offset
828
+ if not get_inverse:
829
+ return {elem: correct_move_to + i for i, elem in enumerate(to_move)}
830
+ else:
831
+ new_idxs = {}
832
+ old_idxs = {}
833
+ for i, elem in enumerate(to_move):
834
+ value = correct_move_to + i
835
+ new_idxs[elem] = value
836
+ old_idxs[value] = elem
837
+ return new_idxs, old_idxs
826
838
 
827
839
 
828
840
  def insert_items(
@@ -833,7 +845,7 @@ def insert_items(
833
845
  """
834
846
  seq: list[Any]
835
847
  to_insert: keys are ints sorted, representing list indexes to insert items.
836
- Values are any, e.g. {1: 200, 0: 200}
848
+ Values are any, e.g. {0: 200, 1: 200}
837
849
  """
838
850
  if to_insert:
839
851
  if seq_len_func and next(reversed(to_insert)) >= len(seq) + len(to_insert):