tksheet 7.1.0__tar.gz → 7.1.2__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 (24) hide show
  1. {tksheet-7.1.0/tksheet.egg-info → tksheet-7.1.2}/PKG-INFO +1 -1
  2. {tksheet-7.1.0 → tksheet-7.1.2}/pyproject.toml +1 -1
  3. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/__init__.py +96 -96
  4. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/functions.py +5 -0
  5. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/main_table.py +66 -75
  6. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/row_index.py +2 -2
  7. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/sheet.py +94 -33
  8. {tksheet-7.1.0 → tksheet-7.1.2/tksheet.egg-info}/PKG-INFO +1 -1
  9. {tksheet-7.1.0 → tksheet-7.1.2}/LICENSE.txt +0 -0
  10. {tksheet-7.1.0 → tksheet-7.1.2}/README.md +0 -0
  11. {tksheet-7.1.0 → tksheet-7.1.2}/setup.cfg +0 -0
  12. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/colors.py +0 -0
  13. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/column_headers.py +0 -0
  14. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/formatters.py +0 -0
  15. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/other_classes.py +0 -0
  16. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/sheet_options.py +0 -0
  17. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/text_editor.py +0 -0
  18. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/themes.py +0 -0
  19. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/top_left_rectangle.py +0 -0
  20. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/types.py +0 -0
  21. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet/vars.py +0 -0
  22. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet.egg-info/SOURCES.txt +0 -0
  23. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet.egg-info/dependency_links.txt +0 -0
  24. {tksheet-7.1.0 → tksheet-7.1.2}/tksheet.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.1.0
3
+ Version: 7.1.2
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
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
  name = "tksheet"
7
7
  description = "Tkinter table / sheet widget"
8
8
  readme = "README.md"
9
- version = "7.1.0"
9
+ version = "7.1.2"
10
10
  authors = [{ name = "ragardner", email = "github@ragardner.simplelogin.com" }]
11
11
  requires-python = ">=3.8"
12
12
  license = {file = "LICENSE.txt"}
@@ -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.2"
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
+ )
@@ -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,
@@ -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
  )
@@ -1098,29 +1099,16 @@ class MainTable(tk.Canvas):
1098
1099
  def get_max_column_idx(self, maxidx: int | None = None) -> int:
1099
1100
  if maxidx is None:
1100
1101
  maxidx = len_to_idx(self.total_data_cols())
1101
- # max column number in cell_options
1102
- if maxidx < (maxk := max(self.cell_options, key=itemgetter(1), default=(0, 0))[1]):
1103
- maxidx = maxk
1104
- # max column number in column_options, index cell options
1105
- for d in (self.col_options, self.CH.cell_options):
1106
- if maxidx < (maxk := max(d, default=0)):
1107
- maxidx = maxk
1108
- # max column number in named spans
1109
- if maxidx < (
1110
- maxk := max(
1111
- (d["from_c"] for d in self.named_spans.values() if isinstance(d["from_c"], int)),
1112
- default=0,
1113
- )
1114
- ):
1115
- maxidx = maxk
1116
- if maxidx < (
1117
- maxk := max(
1118
- (d["upto_c"] for d in self.named_spans.values() if isinstance(d["upto_c"], int)),
1119
- default=0,
1120
- )
1121
- ):
1122
- maxidx = maxk
1123
- return maxidx
1102
+ maxiget = partial(max, key=itemgetter(1))
1103
+ return max(
1104
+ max(self.cell_options, key=itemgetter(1), default=(0, maxidx))[1],
1105
+ max(self.col_options, default=maxidx),
1106
+ max(self.CH.cell_options, default=maxidx),
1107
+ maxiget(map(maxiget, self.tagged_cells.values()), default=(0, maxidx))[1],
1108
+ max(map(max, self.tagged_columns.values()), default=maxidx),
1109
+ max((d.from_c for d in self.named_spans.values() if isinstance(d.from_c, int)), default=maxidx),
1110
+ max((d.upto_c for d in self.named_spans.values() if isinstance(d.upto_c, int)), default=maxidx),
1111
+ )
1124
1112
 
1125
1113
  def get_args_for_move_rows(
1126
1114
  self,
@@ -1328,28 +1316,16 @@ class MainTable(tk.Canvas):
1328
1316
  def get_max_row_idx(self, maxidx: int | None = None) -> int:
1329
1317
  if maxidx is None:
1330
1318
  maxidx = len_to_idx(self.total_data_rows())
1331
- if maxidx < (maxk := max(self.cell_options, key=itemgetter(0), default=(0, 0))[0]):
1332
- maxidx = maxk
1333
- # max row number in row_options, index cell options
1334
- for d in (self.row_options, self.RI.cell_options):
1335
- if maxidx < (maxk := max(d, default=0)):
1336
- maxidx = maxk
1337
- # max row number in named spans
1338
- if maxidx < (
1339
- maxk := max(
1340
- (d["from_r"] for d in self.named_spans.values() if isinstance(d["from_r"], int)),
1341
- default=0,
1342
- )
1343
- ):
1344
- maxidx = maxk
1345
- if maxidx < (
1346
- maxk := max(
1347
- (d["upto_r"] for d in self.named_spans.values() if isinstance(d["upto_r"], int)),
1348
- default=0,
1349
- )
1350
- ):
1351
- maxidx = maxk
1352
- return maxidx
1319
+ maxiget = partial(max, key=itemgetter(0))
1320
+ return max(
1321
+ max(self.cell_options, key=itemgetter(0), default=(maxidx, 0))[0],
1322
+ max(self.row_options, default=maxidx),
1323
+ max(self.RI.cell_options, default=maxidx),
1324
+ maxiget(map(maxiget, self.tagged_cells.values()), default=(maxidx, 0))[0],
1325
+ max(map(max, self.tagged_rows.values()), default=maxidx),
1326
+ max((d.from_r for d in self.named_spans.values() if isinstance(d.from_r, int)), default=maxidx),
1327
+ max((d.upto_r for d in self.named_spans.values() if isinstance(d.upto_r, int)), default=maxidx),
1328
+ )
1353
1329
 
1354
1330
  def get_full_new_idxs(
1355
1331
  self,
@@ -1434,7 +1410,15 @@ class MainTable(tk.Canvas):
1434
1410
  self.CH.cell_options = modification["options"]["CH_cell_options"]
1435
1411
  if "RI_cell_options" in modification["options"]:
1436
1412
  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()}
1413
+ if "tagged_cells" in modification["options"]:
1414
+ self.tagged_cells = modification["options"]["tagged_cells"]
1415
+ if "tagged_rows" in modification["options"]:
1416
+ self.tagged_rows = modification["options"]["tagged_rows"]
1417
+ if "tagged_columns" in modification["options"]:
1418
+ self.tagged_columns = modification["options"]["tagged_columns"]
1419
+ self.named_spans = {
1420
+ k: mod_span_widget(unpickle_obj(v), self.PAR) for k, v in modification["named_spans"].items()
1421
+ }
1438
1422
 
1439
1423
  def undo_modification_invert_event(self, modification: EventDataDict, name: str = "undo") -> bytes | EventDataDict:
1440
1424
  self.deselect("all", redraw=False)
@@ -1709,7 +1693,7 @@ class MainTable(tk.Canvas):
1709
1693
  return False
1710
1694
 
1711
1695
  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
1696
+ selected = self.selected
1713
1697
  self.deselect("all", redraw=False)
1714
1698
  if len(self.row_positions) > 1 and len(self.col_positions) > 1:
1715
1699
  item = self.create_selection_box(
@@ -1719,8 +1703,8 @@ class MainTable(tk.Canvas):
1719
1703
  len(self.col_positions) - 1,
1720
1704
  set_current=False,
1721
1705
  )
1722
- if iid:
1723
- self.set_currently_selected(r, c, item=item)
1706
+ if selected:
1707
+ self.set_currently_selected(selected.row, selected.column, item=item)
1724
1708
  else:
1725
1709
  self.set_currently_selected(0, 0, item=item)
1726
1710
  if redraw:
@@ -3973,7 +3957,7 @@ class MainTable(tk.Canvas):
3973
3957
  # if to_add then it's an undo/redo and don't
3974
3958
  # need to create fresh options
3975
3959
  if create_ops:
3976
- # if rows are none it's a row options span
3960
+ # if cols are none it's a row options span
3977
3961
  if span["from_c"] is None:
3978
3962
  new_ops(
3979
3963
  mod_span(
@@ -4531,6 +4515,9 @@ class MainTable(tk.Canvas):
4531
4515
  "row_options": self.row_options,
4532
4516
  "CH_cell_options": self.CH.cell_options,
4533
4517
  "RI_cell_options": self.RI.cell_options,
4518
+ "tagged_cells": self.tagged_cells,
4519
+ "tagged_rows": self.tagged_rows,
4520
+ "tagged_columns": self.tagged_columns,
4534
4521
  }
4535
4522
  )
4536
4523
 
@@ -6252,10 +6239,10 @@ class MainTable(tk.Canvas):
6252
6239
  return [(box.coords, box.type) for item, box in self.get_selection_items()]
6253
6240
 
6254
6241
  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
6242
+ return any(
6243
+ not r1 and not c1 and r2 == len(self.row_positions) - 1 and c2 == len(self.col_positions) - 1
6244
+ for r1, c1, r2, c2 in self.get_all_selection_boxes()
6245
+ )
6259
6246
 
6260
6247
  def cell_selected(
6261
6248
  self,
@@ -6264,31 +6251,35 @@ class MainTable(tk.Canvas):
6264
6251
  inc_cols: bool = False,
6265
6252
  inc_rows: bool = False,
6266
6253
  ) -> 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
6254
+ return (
6255
+ isinstance(r, int)
6256
+ and isinstance(c, int)
6257
+ and any(
6258
+ box.coords.from_r <= r and box.coords.upto_r > r and box.coords.from_c <= c and box.coords.upto_c > c
6259
+ for item, box in self.get_selection_items(
6260
+ rows=inc_rows,
6261
+ columns=inc_cols,
6262
+ )
6263
+ )
6264
+ )
6274
6265
 
6275
6266
  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
6267
+ return isinstance(c, int) and any(
6268
+ box.coords.from_c <= c and box.coords.upto_c > c
6269
+ for item, box in self.get_selection_items(
6270
+ cells=False,
6271
+ rows=False,
6272
+ )
6273
+ )
6283
6274
 
6284
6275
  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
6276
+ return isinstance(r, int) and any(
6277
+ box.coords.from_r <= r and box.coords.upto_r > r
6278
+ for item, box in self.get_selection_items(
6279
+ cells=False,
6280
+ columns=False,
6281
+ )
6282
+ )
6292
6283
 
6293
6284
  def anything_selected(
6294
6285
  self,
@@ -129,7 +129,7 @@ class RowIndex(tk.Canvas):
129
129
  self.align = kwargs["row_index_align"]
130
130
  self.default_index = kwargs["default_row_index"].lower()
131
131
 
132
- self.reset_tree()
132
+ self.tree_reset()
133
133
  self.basic_bindings()
134
134
 
135
135
  def basic_bindings(self, enable: bool = True) -> None:
@@ -148,7 +148,7 @@ class RowIndex(tk.Canvas):
148
148
  self.unbind("<Double-Button-1>")
149
149
  self.unbind(rc_binding)
150
150
 
151
- def reset_tree(self) -> None:
151
+ def tree_reset(self) -> None:
152
152
  # treeview mode
153
153
  self.tree = {}
154
154
  self.tree_open_ids = set()
@@ -1476,7 +1476,7 @@ class Sheet(tk.Frame):
1476
1476
  if sheet_options:
1477
1477
  self.ops = new_sheet_options()
1478
1478
  if tree:
1479
- self.RI.reset_tree()
1479
+ self.RI.tree_reset()
1480
1480
  self.set_refresh_timer(redraw)
1481
1481
  return self
1482
1482
 
@@ -2998,9 +2998,10 @@ class Sheet(tk.Frame):
2998
2998
 
2999
2999
  def get_selected_min_max(
3000
3000
  self,
3001
- ) -> (
3002
- tuple[int, int, int, int] | tuple[None, None, None, None]
3003
- ): # returns (min_y, min_x, max_y, max_x) of any selections including rows/columns
3001
+ ) -> tuple[int, int, int, int] | tuple[None, None, None, None]:
3002
+ """
3003
+ Returns (min_y, min_x, max_y, max_x) of all selection boxes
3004
+ """
3004
3005
  return self.MT.get_selected_min_max()
3005
3006
 
3006
3007
  # Modifying Selected Cells
@@ -3286,12 +3287,12 @@ class Sheet(tk.Frame):
3286
3287
 
3287
3288
  def get_column_widths(self, canvas_positions: bool = False) -> list[float]:
3288
3289
  if canvas_positions:
3289
- return [int(n) for n in self.MT.col_positions]
3290
+ return self.MT.col_positions
3290
3291
  return self.MT.get_column_widths()
3291
3292
 
3292
3293
  def get_row_heights(self, canvas_positions: bool = False) -> list[float]:
3293
3294
  if canvas_positions:
3294
- return [int(n) for n in self.MT.row_positions]
3295
+ return self.MT.row_positions
3295
3296
  return self.MT.get_row_heights()
3296
3297
 
3297
3298
  def set_column_widths(
@@ -4391,6 +4392,61 @@ class Sheet(tk.Frame):
4391
4392
  )
4392
4393
  return self
4393
4394
 
4395
+ def tree_reset(self) -> Sheet:
4396
+ self.deselect()
4397
+ self.RI.tree_reset()
4398
+ return self
4399
+
4400
+ def tree_get_open(self) -> set[str]:
4401
+ """
4402
+ Returns the set[str] of iids that are open in the treeview
4403
+ """
4404
+ return self.RI.tree_open_ids
4405
+
4406
+ def tree_set_open(self, open_ids: set[str]) -> Sheet:
4407
+ """
4408
+ Accepts set[str] of iids that are open in the treeview
4409
+ Closes everything else
4410
+ """
4411
+ self.RI.tree_open_ids = open_ids
4412
+ self.hide_rows(
4413
+ set(self.MT.displayed_rows),
4414
+ redraw=False,
4415
+ deselect_all=False,
4416
+ data_indexes=True,
4417
+ )
4418
+ self.show_rows(
4419
+ (self.RI.tree_rns[iid] for iid in self.get_children("")),
4420
+ redraw=False,
4421
+ deselect_all=True,
4422
+ )
4423
+ self.tree_open(*open_ids)
4424
+ return self
4425
+
4426
+ def tree_open(self, *items) -> Sheet:
4427
+ """
4428
+ If used without args all items are opened
4429
+ """
4430
+ if items:
4431
+ for item in items:
4432
+ self.item(item, open_=True)
4433
+ else:
4434
+ for item in self.get_children():
4435
+ self.item(item, open_=True)
4436
+ return self
4437
+
4438
+ def tree_close(self, *items) -> Sheet:
4439
+ """
4440
+ If used without args all items are closed
4441
+ """
4442
+ if items:
4443
+ for item in items:
4444
+ self.item(item, open_=False)
4445
+ else:
4446
+ for item in self.get_children():
4447
+ self.item(item, open_=False)
4448
+ return self
4449
+
4394
4450
  def insert(
4395
4451
  self,
4396
4452
  parent: str = "",
@@ -4460,7 +4516,12 @@ class Sheet(tk.Frame):
4460
4516
  text: str | None = None,
4461
4517
  values: list | None = None,
4462
4518
  open_: bool | None = None,
4463
- ) -> DotDict:
4519
+ ) -> DotDict | Sheet:
4520
+ """
4521
+ Modify options for item
4522
+ If no options are set then returns DotDict of options for item
4523
+ Else returns Sheet
4524
+ """
4464
4525
  if not (item := item.lower()) or item not in self.RI.tree:
4465
4526
  raise ValueError(f"Item '{item}' does not exist.")
4466
4527
  if isinstance(iid, str):
@@ -4479,28 +4540,33 @@ class Sheet(tk.Frame):
4479
4540
  if isinstance(values, list):
4480
4541
  self.set_data(self.RI.tree_rns[item], values)
4481
4542
  if isinstance(open_, bool):
4482
- if not self.RI.tree[item].children or not open_:
4543
+ if self.RI.tree[item].children:
4544
+ if open_:
4545
+ self.RI.tree_open_ids.add(item)
4546
+ self.show_rows(
4547
+ (self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True)),
4548
+ redraw=False,
4549
+ deselect_all=False,
4550
+ )
4551
+ else:
4552
+ self.RI.tree_open_ids.discard(item)
4553
+ self.hide_rows(
4554
+ (self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item)),
4555
+ redraw=False,
4556
+ deselect_all=False,
4557
+ data_indexes=True,
4558
+ )
4559
+ else:
4483
4560
  self.RI.tree_open_ids.discard(item)
4484
- if open_:
4485
- self.RI.tree_open_ids.add(item)
4486
- self.show_rows(
4487
- (self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True)),
4488
- redraw=False,
4489
- deselect_all=False,
4490
- )
4491
- elif self.RI.tree[item].children:
4492
- self.hide_rows(
4493
- (self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item)),
4494
- redraw=False,
4495
- deselect_all=False,
4496
- data_indexes=True,
4497
- )
4498
- self.set_refresh_timer(isinstance(text, str) or isinstance(values, list) or isinstance(open_, bool))
4499
- return DotDict(
4500
- text=self.RI.tree[item].text,
4501
- values=self[self.RI.tree_rns[item]].options(ndim=1).data,
4502
- open_=item in self.RI.tree_open_ids,
4503
- )
4561
+ get = not (isinstance(iid, str) or isinstance(text, str) or isinstance(values, list) or isinstance(open_, bool))
4562
+ self.set_refresh_timer(redraw=not get)
4563
+ if get:
4564
+ return DotDict(
4565
+ text=self.RI.tree[item].text,
4566
+ values=self[self.RI.tree_rns[item]].options(ndim=1).data,
4567
+ open_=item in self.RI.tree_open_ids,
4568
+ )
4569
+ return self
4504
4570
 
4505
4571
  def itemrow(self, item: str) -> int:
4506
4572
  return self.RI.tree_rns[item.lower()]
@@ -4522,11 +4588,6 @@ class Sheet(tk.Frame):
4522
4588
  else:
4523
4589
  yield from (n.iid for n in self.RI.tree[item].children)
4524
4590
 
4525
- def reset_tree(self) -> Sheet:
4526
- self.deselect()
4527
- self.RI.reset_tree()
4528
- return self
4529
-
4530
4591
  def del_items(self, *items) -> Sheet:
4531
4592
  """
4532
4593
  Also deletes all descendants of items
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.1.0
3
+ Version: 7.1.2
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes