tksheet 7.1.0__py3-none-any.whl → 7.1.1__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 CHANGED
@@ -1,96 +1,96 @@
1
- # ruff: noqa: F401
2
-
3
- """
4
- tksheet - A Python tkinter table widget
5
- """
6
-
7
- __version__ = "7.1.0"
8
-
9
- from .colors import (
10
- color_map,
11
- )
12
- from .column_headers import ColumnHeaders
13
- from .formatters import (
14
- Formatter,
15
- bool_formatter,
16
- data_to_str,
17
- float_formatter,
18
- float_to_str,
19
- format_data,
20
- formatter,
21
- get_clipboard_data,
22
- get_data_with_valid_check,
23
- int_formatter,
24
- is_bool_like,
25
- is_none_like,
26
- percentage_formatter,
27
- percentage_to_str,
28
- to_bool,
29
- to_float,
30
- to_int,
31
- to_str,
32
- try_to_bool,
33
- )
34
- from .functions import (
35
- alpha2idx,
36
- alpha2num,
37
- consecutive_chunks,
38
- data_to_displayed_idxs,
39
- displayed_to_data_idxs,
40
- dropdown_search_function,
41
- event_dict,
42
- get_checkbox_dict,
43
- get_checkbox_kwargs,
44
- get_checkbox_points,
45
- get_dropdown_dict,
46
- get_dropdown_kwargs,
47
- get_index_of_gap_in_sorted_integer_seq_forward,
48
- get_index_of_gap_in_sorted_integer_seq_reverse,
49
- get_n2a,
50
- get_new_indexes,
51
- get_seq_without_gaps_at_index,
52
- is_iterable,
53
- move_elements_by_mapping,
54
- move_elements_to,
55
- num2alpha,
56
- span_dict,
57
- tksheet_type_error,
58
- )
59
- from .main_table import MainTable
60
- from .other_classes import (
61
- DotDict,
62
- DraggedRowColumn,
63
- DrawnItem,
64
- EventDataDict,
65
- GeneratedMouseEvent,
66
- Selected,
67
- Span,
68
- SpanRange,
69
- TextCfg,
70
- )
71
- from .row_index import RowIndex
72
- from .sheet import Dropdown, Sheet
73
- from .sheet_options import new_sheet_options
74
- from .text_editor import (
75
- TextEditor,
76
- TextEditorTkText,
77
- )
78
- from .themes import (
79
- theme_black,
80
- theme_dark,
81
- theme_dark_blue,
82
- theme_dark_green,
83
- theme_light_blue,
84
- theme_light_green,
85
- )
86
- from .top_left_rectangle import TopLeftRectangle
87
- from .vars import (
88
- USER_OS,
89
- ctrl_key,
90
- emitted_events,
91
- falsy,
92
- nonelike,
93
- rc_binding,
94
- symbols_set,
95
- truthy,
96
- )
1
+ # ruff: noqa: F401
2
+
3
+ """
4
+ tksheet - A Python tkinter table widget
5
+ """
6
+
7
+ __version__ = "7.1.1"
8
+
9
+ from .colors import (
10
+ color_map,
11
+ )
12
+ from .column_headers import ColumnHeaders
13
+ from .formatters import (
14
+ Formatter,
15
+ bool_formatter,
16
+ data_to_str,
17
+ float_formatter,
18
+ float_to_str,
19
+ format_data,
20
+ formatter,
21
+ get_clipboard_data,
22
+ get_data_with_valid_check,
23
+ int_formatter,
24
+ is_bool_like,
25
+ is_none_like,
26
+ percentage_formatter,
27
+ percentage_to_str,
28
+ to_bool,
29
+ to_float,
30
+ to_int,
31
+ to_str,
32
+ try_to_bool,
33
+ )
34
+ from .functions import (
35
+ alpha2idx,
36
+ alpha2num,
37
+ consecutive_chunks,
38
+ data_to_displayed_idxs,
39
+ displayed_to_data_idxs,
40
+ dropdown_search_function,
41
+ event_dict,
42
+ get_checkbox_dict,
43
+ get_checkbox_kwargs,
44
+ get_checkbox_points,
45
+ get_dropdown_dict,
46
+ get_dropdown_kwargs,
47
+ get_index_of_gap_in_sorted_integer_seq_forward,
48
+ get_index_of_gap_in_sorted_integer_seq_reverse,
49
+ get_n2a,
50
+ get_new_indexes,
51
+ get_seq_without_gaps_at_index,
52
+ is_iterable,
53
+ move_elements_by_mapping,
54
+ move_elements_to,
55
+ num2alpha,
56
+ span_dict,
57
+ tksheet_type_error,
58
+ )
59
+ from .main_table import MainTable
60
+ from .other_classes import (
61
+ DotDict,
62
+ DraggedRowColumn,
63
+ DrawnItem,
64
+ EventDataDict,
65
+ GeneratedMouseEvent,
66
+ Selected,
67
+ Span,
68
+ SpanRange,
69
+ TextCfg,
70
+ )
71
+ from .row_index import RowIndex
72
+ from .sheet import Dropdown, Sheet
73
+ from .sheet_options import new_sheet_options
74
+ from .text_editor import (
75
+ TextEditor,
76
+ TextEditorTkText,
77
+ )
78
+ from .themes import (
79
+ theme_black,
80
+ theme_dark,
81
+ theme_dark_blue,
82
+ theme_dark_green,
83
+ theme_light_blue,
84
+ theme_light_green,
85
+ )
86
+ from .top_left_rectangle import TopLeftRectangle
87
+ from .vars import (
88
+ USER_OS,
89
+ ctrl_key,
90
+ emitted_events,
91
+ falsy,
92
+ nonelike,
93
+ rc_binding,
94
+ symbols_set,
95
+ truthy,
96
+ )
tksheet/functions.py CHANGED
@@ -1254,6 +1254,11 @@ def mod_span(
1254
1254
  return to_set_to
1255
1255
 
1256
1256
 
1257
+ def mod_span_widget(span: Span, widget: object) -> Span:
1258
+ span.widget = widget
1259
+ return span
1260
+
1261
+
1257
1262
  def mod_event_val(
1258
1263
  event_data: EventDataDict,
1259
1264
  val: object,
tksheet/main_table.py CHANGED
@@ -69,6 +69,7 @@ from .functions import (
69
69
  move_elements_by_mapping,
70
70
  pickle_obj,
71
71
  span_idxs_post_move,
72
+ mod_span_widget,
72
73
  try_binding,
73
74
  unpickle_obj,
74
75
  )
@@ -1434,7 +1435,15 @@ class MainTable(tk.Canvas):
1434
1435
  self.CH.cell_options = modification["options"]["CH_cell_options"]
1435
1436
  if "RI_cell_options" in modification["options"]:
1436
1437
  self.RI.cell_options = modification["options"]["RI_cell_options"]
1437
- self.named_spans = {k: unpickle_obj(v) for k, v in modification["named_spans"].items()}
1438
+ if "tagged_cells" in modification["options"]:
1439
+ self.tagged_cells = modification["options"]["tagged_cells"]
1440
+ if "tagged_rows" in modification["options"]:
1441
+ self.tagged_rows = modification["options"]["tagged_rows"]
1442
+ if "tagged_columns" in modification["options"]:
1443
+ self.tagged_columns = modification["options"]["tagged_columns"]
1444
+ self.named_spans = {
1445
+ k: mod_span_widget(unpickle_obj(v), self.PAR) for k, v in modification["named_spans"].items()
1446
+ }
1438
1447
 
1439
1448
  def undo_modification_invert_event(self, modification: EventDataDict, name: str = "undo") -> bytes | EventDataDict:
1440
1449
  self.deselect("all", redraw=False)
@@ -1709,7 +1718,7 @@ class MainTable(tk.Canvas):
1709
1718
  return False
1710
1719
 
1711
1720
  def select_all(self, redraw: bool = True, run_binding_func: bool = True) -> None:
1712
- iid, r, c = self.selected.iid, self.selected.row, self.selected.column
1721
+ selected = self.selected
1713
1722
  self.deselect("all", redraw=False)
1714
1723
  if len(self.row_positions) > 1 and len(self.col_positions) > 1:
1715
1724
  item = self.create_selection_box(
@@ -1719,8 +1728,8 @@ class MainTable(tk.Canvas):
1719
1728
  len(self.col_positions) - 1,
1720
1729
  set_current=False,
1721
1730
  )
1722
- if iid:
1723
- self.set_currently_selected(r, c, item=item)
1731
+ if selected:
1732
+ self.set_currently_selected(selected.row, selected.column, item=item)
1724
1733
  else:
1725
1734
  self.set_currently_selected(0, 0, item=item)
1726
1735
  if redraw:
@@ -4531,6 +4540,9 @@ class MainTable(tk.Canvas):
4531
4540
  "row_options": self.row_options,
4532
4541
  "CH_cell_options": self.CH.cell_options,
4533
4542
  "RI_cell_options": self.RI.cell_options,
4543
+ "tagged_cells": self.tagged_cells,
4544
+ "tagged_rows": self.tagged_rows,
4545
+ "tagged_columns": self.tagged_columns,
4534
4546
  }
4535
4547
  )
4536
4548
 
@@ -6252,10 +6264,10 @@ class MainTable(tk.Canvas):
6252
6264
  return [(box.coords, box.type) for item, box in self.get_selection_items()]
6253
6265
 
6254
6266
  def all_selected(self) -> bool:
6255
- for r1, c1, r2, c2 in self.get_all_selection_boxes():
6256
- if not r1 and not c1 and r2 == len(self.row_positions) - 1 and c2 == len(self.col_positions) - 1:
6257
- return True
6258
- return False
6267
+ return any(
6268
+ not r1 and not c1 and r2 == len(self.row_positions) - 1 and c2 == len(self.col_positions) - 1
6269
+ for r1, c1, r2, c2 in self.get_all_selection_boxes()
6270
+ )
6259
6271
 
6260
6272
  def cell_selected(
6261
6273
  self,
@@ -6264,31 +6276,35 @@ class MainTable(tk.Canvas):
6264
6276
  inc_cols: bool = False,
6265
6277
  inc_rows: bool = False,
6266
6278
  ) -> bool:
6267
- if not isinstance(r, int) or not isinstance(c, int):
6268
- return False
6269
- for item, box in self.get_selection_items(rows=inc_rows, columns=inc_cols):
6270
- r1, c1, r2, c2 = box.coords
6271
- if r1 <= r and c1 <= c and r2 > r and c2 > c:
6272
- return True
6273
- return False
6279
+ return (
6280
+ isinstance(r, int)
6281
+ and isinstance(c, int)
6282
+ and any(
6283
+ box.coords.from_r <= r and box.coords.upto_r > r and box.coords.from_c <= c and box.coords.upto_c > c
6284
+ for item, box in self.get_selection_items(
6285
+ rows=inc_rows,
6286
+ columns=inc_cols,
6287
+ )
6288
+ )
6289
+ )
6274
6290
 
6275
6291
  def col_selected(self, c: int) -> bool:
6276
- if not isinstance(c, int):
6277
- return False
6278
- for item, box in self.get_selection_items(cells=False, rows=False):
6279
- r1, c1, r2, c2 = box.coords
6280
- if c1 <= c and c2 > c:
6281
- return True
6282
- return False
6292
+ return isinstance(c, int) and any(
6293
+ box.coords.from_c <= c and box.coords.upto_c > c
6294
+ for item, box in self.get_selection_items(
6295
+ cells=False,
6296
+ columns=False,
6297
+ )
6298
+ )
6283
6299
 
6284
6300
  def row_selected(self, r: int) -> bool:
6285
- if not isinstance(r, int):
6286
- return False
6287
- for item, box in self.get_selection_items(cells=False, columns=False):
6288
- r1, c1, r2, c2 = box.coords
6289
- if r1 <= r and r2 > r:
6290
- return True
6291
- return False
6301
+ return isinstance(r, int) and any(
6302
+ box.coords.from_r <= r and box.coords.upto_r > r
6303
+ for item, box in self.get_selection_items(
6304
+ cells=False,
6305
+ columns=False,
6306
+ )
6307
+ )
6292
6308
 
6293
6309
  def anything_selected(
6294
6310
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.1.0
3
+ Version: 7.1.1
4
4
  Summary: Tkinter table / sheet widget
5
5
  Author-email: ragardner <github@ragardner.simplelogin.com>
6
6
  License: Copyright (c) 2019 ragardner and open source contributors
@@ -1,9 +1,9 @@
1
- tksheet/__init__.py,sha256=BtFx0z_hW793tGDNe8VmnGEjZKAdSXxq6gHyklEky7s,1970
1
+ tksheet/__init__.py,sha256=-P8w8KS0O82elJMwvIYsdoTCWYEV3mRGX_60GToTxWI,1874
2
2
  tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
3
  tksheet/column_headers.py,sha256=1I49CQS4unBcJ-y044R-DtYhJ4zUplrOfImOk8qHIj8,99396
4
4
  tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
- tksheet/functions.py,sha256=cMnWgE-rZVrCH8wXKKtg8uXn60pd5MuOE3Bm9T94ePM,38546
6
- tksheet/main_table.py,sha256=QM4peTylZP7omXriKQO9kP-ZwHGDSILIXECjy-SEFSw,318674
5
+ tksheet/functions.py,sha256=NnBFBvTqT6VhCK8pFlXqTwKekKpcsCYeuxaALcJeVzw,38651
6
+ tksheet/main_table.py,sha256=SwJVPoivJuu8D37lvoo1Hn52P75TvjFwg-E2QHILhuw,319302
7
7
  tksheet/other_classes.py,sha256=s559IxoFEeAgxTKrrHZnAeXUXWIEmiP4tBncIdQIXSQ,13544
8
8
  tksheet/row_index.py,sha256=4Q_J83AKKZhajeK23_deby9CXfL4wl1MOWnSu8LW2PU,104428
9
9
  tksheet/sheet.py,sha256=66AKMY-wNiLi2briyUlbUHtsVNwEWKnljx58q1c1tKU,254086
@@ -13,8 +13,8 @@ tksheet/themes.py,sha256=OwUe31NRbosjw3ZoZsMyB8lNVyYin9YcKLhCturi5q8,13398
13
13
  tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
14
14
  tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
15
  tksheet/vars.py,sha256=Iukk7-MMT9X7vv0m3nQPKzbp2Iw2Pg1wJEW7js919Mo,2092
16
- tksheet-7.1.0.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
- tksheet-7.1.0.dist-info/METADATA,sha256=ue-jn_hvJCVDRsFhOc3z5ikKDT5joY5s2JggO-4-Ksk,6013
18
- tksheet-7.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- tksheet-7.1.0.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
- tksheet-7.1.0.dist-info/RECORD,,
16
+ tksheet-7.1.1.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
+ tksheet-7.1.1.dist-info/METADATA,sha256=2PCCoZogg-1iMfDoYbKCV6a_2N8Tf0kYgIX4o908q98,6013
18
+ tksheet-7.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ tksheet-7.1.1.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
+ tksheet-7.1.1.dist-info/RECORD,,