tksheet 7.2.8__py3-none-any.whl → 7.2.9__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
@@ -4,7 +4,7 @@
4
4
  tksheet - A Python tkinter table widget
5
5
  """
6
6
 
7
- __version__ = "7.2.8"
7
+ __version__ = "7.2.9"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
tksheet/column_headers.py CHANGED
@@ -946,7 +946,7 @@ class ColumnHeaders(tk.Canvas):
946
946
  run_binding_func: bool = True,
947
947
  ext: bool = False,
948
948
  ) -> int:
949
- boxes_to_hide = tuple(iid for iid in self.MT.selection_boxes)
949
+ boxes_to_hide = tuple(self.MT.selection_boxes)
950
950
  fill_iid = self.MT.create_selection_box(0, c, len(self.MT.row_positions) - 1, c + 1, "columns", ext=ext)
951
951
  for iid in boxes_to_hide:
952
952
  self.MT.hide_selection_box(iid)
@@ -989,7 +989,7 @@ class ColumnHeaders(tk.Canvas):
989
989
  y1,
990
990
  x2,
991
991
  y2,
992
- radius=8 if self.PAR.ops.rounded_boxes else 0,
992
+ radius=5 if self.PAR.ops.rounded_boxes else 0,
993
993
  )
994
994
  if isinstance(iid, int):
995
995
  self.coords(iid, coords)
@@ -1314,24 +1314,23 @@ class ColumnHeaders(tk.Canvas):
1314
1314
  if open_:
1315
1315
  # up arrow
1316
1316
  points = (
1317
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
1317
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
1318
1318
  y1 + mid_y + small_mod,
1319
- x2 - 3 - small_mod - small_mod,
1319
+ x2 - 4 - small_mod - small_mod,
1320
1320
  y1 + mid_y - small_mod,
1321
- x2 - 3,
1321
+ x2 - 4,
1322
1322
  y1 + mid_y + small_mod,
1323
1323
  )
1324
1324
  else:
1325
1325
  # down arrow
1326
1326
  points = (
1327
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
1327
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
1328
1328
  y1 + mid_y - small_mod,
1329
- x2 - 3 - small_mod - small_mod,
1329
+ x2 - 4 - small_mod - small_mod,
1330
1330
  y1 + mid_y + small_mod,
1331
- x2 - 3,
1331
+ x2 - 4,
1332
1332
  y1 + mid_y - small_mod,
1333
1333
  )
1334
-
1335
1334
  if self.hidd_dropdown:
1336
1335
  t, sh = self.hidd_dropdown.popitem()
1337
1336
  self.coords(t, points)
@@ -1341,10 +1340,13 @@ class ColumnHeaders(tk.Canvas):
1341
1340
  self.itemconfig(t, fill=fill, tag=tag, state="normal")
1342
1341
  self.lift(t)
1343
1342
  else:
1344
- t = self.create_polygon(
1343
+ t = self.create_line(
1345
1344
  points,
1346
1345
  fill=fill,
1347
1346
  tag=tag,
1347
+ width=2,
1348
+ capstyle=tk.ROUND,
1349
+ joinstyle=tk.BEVEL,
1348
1350
  )
1349
1351
  self.disp_dropdown[t] = True
1350
1352
 
tksheet/functions.py CHANGED
@@ -545,7 +545,7 @@ def rounded_box_coords(
545
545
  y1: float,
546
546
  x2: float,
547
547
  y2: float,
548
- radius: int = 8,
548
+ radius: int = 5,
549
549
  ) -> tuple[float]:
550
550
  return (
551
551
  x1 + radius,
tksheet/main_table.py CHANGED
@@ -25,6 +25,7 @@ from itertools import (
25
25
  accumulate,
26
26
  chain,
27
27
  cycle,
28
+ filterfalse,
28
29
  islice,
29
30
  repeat,
30
31
  )
@@ -696,8 +697,9 @@ class MainTable(tk.Canvas):
696
697
  selected=self.selected,
697
698
  )
698
699
  if self.selected:
699
- selected_r = self.selected.row
700
- selected_c = self.selected.column
700
+ selected_r = self.selected.box.from_r
701
+ selected_c = self.selected.box.from_c
702
+ curr_coords = (self.selected.row, self.selected.column)
701
703
  elif not self.selected and not self.PAR.ops.paste_can_expand_x and not self.PAR.ops.paste_can_expand_y:
702
704
  return
703
705
  else:
@@ -710,6 +712,7 @@ class MainTable(tk.Canvas):
710
712
  selected_c, selected_r = len(self.col_positions) - 1, 0
711
713
  elif len(self.row_positions) > 1 and len(self.col_positions) > 1:
712
714
  selected_c, selected_r = 0, len(self.row_positions) - 1
715
+ curr_coords = (selected_r, selected_c)
713
716
  try:
714
717
  data = get_data_from_clipboard(
715
718
  widget=self,
@@ -915,13 +918,17 @@ class MainTable(tk.Canvas):
915
918
  else:
916
919
  selboxc = selected_c_adjusted_new_data_numcols
917
920
  self.deselect("all", redraw=False)
918
- self.create_selection_box(
919
- selected_r,
920
- selected_c,
921
- selboxr,
922
- selboxc,
923
- "cells",
924
- run_binding=True,
921
+ self.set_currently_selected(
922
+ *curr_coords,
923
+ item=self.create_selection_box(
924
+ selected_r,
925
+ selected_c,
926
+ selboxr,
927
+ selboxc,
928
+ type_="cells",
929
+ set_current=False,
930
+ run_binding=True,
931
+ ),
925
932
  )
926
933
  event_data["selection_boxes"] = self.get_boxes()
927
934
  event_data["selected"] = self.selected
@@ -3773,11 +3780,10 @@ class MainTable(tk.Canvas):
3773
3780
  colpos = self.PAR.ops.default_column_width
3774
3781
  if isinstance(ncols, int):
3775
3782
  self.set_col_positions(itr=repeat(colpos, ncols))
3783
+ elif self.all_columns_displayed:
3784
+ self.set_col_positions(itr=repeat(colpos, self.total_data_cols()))
3776
3785
  else:
3777
- if self.all_columns_displayed:
3778
- self.set_col_positions(itr=repeat(colpos, self.total_data_cols()))
3779
- else:
3780
- self.set_col_positions(itr=repeat(colpos, len(self.displayed_columns)))
3786
+ self.set_col_positions(itr=repeat(colpos, len(self.displayed_columns)))
3781
3787
 
3782
3788
  def set_row_positions(self, itr: Iterator[float]) -> None:
3783
3789
  self.row_positions = list(accumulate(chain([0], itr)))
@@ -3786,11 +3792,10 @@ class MainTable(tk.Canvas):
3786
3792
  rowpos = self.get_default_row_height()
3787
3793
  if isinstance(nrows, int):
3788
3794
  self.set_row_positions(itr=repeat(rowpos, nrows))
3795
+ elif self.all_rows_displayed:
3796
+ self.set_row_positions(itr=repeat(rowpos, self.total_data_rows()))
3789
3797
  else:
3790
- if self.all_rows_displayed:
3791
- self.set_row_positions(itr=repeat(rowpos, self.total_data_rows()))
3792
- else:
3793
- self.set_row_positions(itr=repeat(rowpos, len(self.displayed_rows)))
3798
+ self.set_row_positions(itr=repeat(rowpos, len(self.displayed_rows)))
3794
3799
 
3795
3800
  def del_col_position(self, idx: int, deselect_all: bool = False):
3796
3801
  if deselect_all:
@@ -4453,7 +4458,7 @@ class MainTable(tk.Canvas):
4453
4458
  if isinstance(displayed_rows, list):
4454
4459
  self.displayed_rows = displayed_rows
4455
4460
  elif not self.all_rows_displayed:
4456
- # push displayed indexes by one for every inserted column
4461
+ # push displayed indexes by one for every inserted row
4457
4462
  self.displayed_rows.sort()
4458
4463
  # highest index is first in rows
4459
4464
  up_to = len(self.displayed_rows)
@@ -4718,9 +4723,10 @@ class MainTable(tk.Canvas):
4718
4723
  named_spans=self.get_spans_to_del_from_cols(cols=cols_set),
4719
4724
  )
4720
4725
  if not self.all_columns_displayed:
4721
- self.displayed_columns = [c for c in self.displayed_columns if c not in cols_set]
4722
- for c in cols:
4723
- self.displayed_columns = [dc if c > dc else dc - 1 for dc in self.displayed_columns]
4726
+ self.displayed_columns = [
4727
+ c if not (num := bisect_left(cols, c)) else c - num
4728
+ for c in filterfalse(cols_set.__contains__, self.displayed_columns)
4729
+ ]
4724
4730
  return event_data
4725
4731
 
4726
4732
  def delete_columns_displayed(self, cols: list, event_data: dict) -> EventDataDict:
@@ -4773,9 +4779,10 @@ class MainTable(tk.Canvas):
4773
4779
  named_spans=self.get_spans_to_del_from_rows(rows=rows_set),
4774
4780
  )
4775
4781
  if not self.all_rows_displayed:
4776
- self.displayed_rows = [r for r in self.displayed_rows if r not in rows_set]
4777
- for r in rows:
4778
- self.displayed_rows = [dr if r > dr else dr - 1 for dr in self.displayed_rows]
4782
+ self.displayed_rows = [
4783
+ r if not (num := bisect_left(rows, r)) else r - num
4784
+ for r in filterfalse(rows_set.__contains__, self.displayed_rows)
4785
+ ]
4779
4786
  return event_data
4780
4787
 
4781
4788
  def delete_rows_displayed(self, rows: list, event_data: dict) -> EventDataDict:
@@ -4847,20 +4854,23 @@ class MainTable(tk.Canvas):
4847
4854
  ) -> list[int] | None:
4848
4855
  if rows is None and all_rows_displayed is None:
4849
4856
  return list(range(self.total_data_rows())) if self.all_rows_displayed else self.displayed_rows
4850
- total_data_rows = None
4851
- if (rows is not None and rows != self.displayed_rows) or (all_rows_displayed and not self.all_rows_displayed):
4852
- self.purge_undo_and_redo_stack()
4853
4857
  if rows is not None and rows != self.displayed_rows:
4858
+ self.purge_undo_and_redo_stack()
4854
4859
  self.displayed_rows = sorted(rows)
4855
- if all_rows_displayed:
4856
- if not self.all_rows_displayed:
4857
- total_data_rows = self.total_data_rows()
4858
- self.displayed_rows = list(range(total_data_rows))
4859
- self.all_rows_displayed = True
4860
- elif all_rows_displayed is not None and not all_rows_displayed:
4861
- self.all_rows_displayed = False
4860
+ # setting all_rows_displayed
4861
+ if all_rows_displayed is not None:
4862
+ # setting it to True and it's currently False
4863
+ if all_rows_displayed and not self.all_rows_displayed:
4864
+ self.purge_undo_and_redo_stack()
4865
+ self.all_rows_displayed = True
4866
+ # setting it to False and it's currently True
4867
+ elif not all_rows_displayed and self.all_rows_displayed:
4868
+ # if rows is None then displayed_rows needs to be reset
4869
+ if rows is None:
4870
+ self.displayed_rows = list(range(self.total_data_rows()))
4871
+ self.all_rows_displayed = False
4862
4872
  if reset_row_positions:
4863
- self.reset_row_positions(nrows=total_data_rows)
4873
+ self.reset_row_positions()
4864
4874
  if deselect_all:
4865
4875
  self.deselect("all", redraw=False)
4866
4876
 
@@ -4873,22 +4883,23 @@ class MainTable(tk.Canvas):
4873
4883
  ) -> list[int] | None:
4874
4884
  if columns is None and all_columns_displayed is None:
4875
4885
  return list(range(self.total_data_cols())) if self.all_columns_displayed else self.displayed_columns
4876
- total_data_cols = None
4877
- if (columns is not None and columns != self.displayed_columns) or (
4878
- all_columns_displayed and not self.all_columns_displayed
4879
- ):
4880
- self.purge_undo_and_redo_stack()
4881
4886
  if columns is not None and columns != self.displayed_columns:
4887
+ self.purge_undo_and_redo_stack()
4882
4888
  self.displayed_columns = sorted(columns)
4883
- if all_columns_displayed:
4884
- if not self.all_columns_displayed:
4885
- total_data_cols = self.total_data_cols()
4886
- self.displayed_columns = list(range(total_data_cols))
4887
- self.all_columns_displayed = True
4888
- elif all_columns_displayed is not None and not all_columns_displayed:
4889
- self.all_columns_displayed = False
4889
+ # setting all_columns_displayed
4890
+ if all_columns_displayed is not None:
4891
+ # setting it to True and it's currently False
4892
+ if all_columns_displayed and not self.all_columns_displayed:
4893
+ self.purge_undo_and_redo_stack()
4894
+ self.all_columns_displayed = True
4895
+ # setting it to False and it's currently True
4896
+ elif not all_columns_displayed and self.all_columns_displayed:
4897
+ # if columns is None then displayed_columns needs to be reset
4898
+ if columns is None:
4899
+ self.displayed_columns = list(range(self.total_data_cols()))
4900
+ self.all_columns_displayed = False
4890
4901
  if reset_col_positions:
4891
- self.reset_col_positions(ncols=total_data_cols)
4902
+ self.reset_col_positions()
4892
4903
  if deselect_all:
4893
4904
  self.deselect("all", redraw=False)
4894
4905
 
@@ -5245,21 +5256,21 @@ class MainTable(tk.Canvas):
5245
5256
  if open_:
5246
5257
  # up arrow
5247
5258
  points = (
5248
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
5259
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
5249
5260
  y1 + mid_y + small_mod,
5250
- x2 - 3 - small_mod - small_mod,
5261
+ x2 - 4 - small_mod - small_mod,
5251
5262
  y1 + mid_y - small_mod,
5252
- x2 - 3,
5263
+ x2 - 4,
5253
5264
  y1 + mid_y + small_mod,
5254
5265
  )
5255
5266
  else:
5256
5267
  # down arrow
5257
5268
  points = (
5258
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
5269
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
5259
5270
  y1 + mid_y - small_mod,
5260
- x2 - 3 - small_mod - small_mod,
5271
+ x2 - 4 - small_mod - small_mod,
5261
5272
  y1 + mid_y + small_mod,
5262
- x2 - 3,
5273
+ x2 - 4,
5263
5274
  y1 + mid_y - small_mod,
5264
5275
  )
5265
5276
  if self.hidd_dropdown:
@@ -5271,10 +5282,13 @@ class MainTable(tk.Canvas):
5271
5282
  self.itemconfig(t, fill=fill, tag=tag, state="normal")
5272
5283
  self.lift(t)
5273
5284
  else:
5274
- t = self.create_polygon(
5285
+ t = self.create_line(
5275
5286
  points,
5276
5287
  fill=fill,
5277
5288
  tag=tag,
5289
+ width=2,
5290
+ capstyle=tk.ROUND,
5291
+ joinstyle=tk.BEVEL,
5278
5292
  )
5279
5293
  self.disp_dropdown[t] = True
5280
5294
 
@@ -5957,7 +5971,7 @@ class MainTable(tk.Canvas):
5957
5971
  if not self.PAR.ops.rounded_boxes or not x2 - x1 or not y2 - y1:
5958
5972
  radius = 0
5959
5973
  else:
5960
- radius = 8
5974
+ radius = 5
5961
5975
  coords = rounded_box_coords(
5962
5976
  x1,
5963
5977
  y1,
@@ -6182,7 +6196,7 @@ class MainTable(tk.Canvas):
6182
6196
  x1, y1, x2, y2 = self.box_coords_x_canvas_coords(r1, c1, r2, c2, type_)
6183
6197
  self.display_box(x1, y1, x2, y2, fill=mt_bg, outline="", state=state, tags=type_, width=1, iid=fill_iid)
6184
6198
  self.RI.display_box(
6185
- 1,
6199
+ 0,
6186
6200
  y1,
6187
6201
  self.RI.current_width - 1,
6188
6202
  y2,
tksheet/row_index.py CHANGED
@@ -957,7 +957,7 @@ class RowIndex(tk.Canvas):
957
957
  run_binding_func: bool = True,
958
958
  ext: bool = False,
959
959
  ) -> int:
960
- boxes_to_hide = tuple(iid for iid in self.MT.selection_boxes)
960
+ boxes_to_hide = tuple(self.MT.selection_boxes)
961
961
  fill_iid = self.MT.create_selection_box(r, 0, r + 1, len(self.MT.col_positions) - 1, "rows", ext=ext)
962
962
  for iid in boxes_to_hide:
963
963
  self.MT.hide_selection_box(iid)
@@ -1000,7 +1000,7 @@ class RowIndex(tk.Canvas):
1000
1000
  y1,
1001
1001
  x2,
1002
1002
  y2,
1003
- radius=8 if self.PAR.ops.rounded_boxes else 0,
1003
+ radius=5 if self.PAR.ops.rounded_boxes else 0,
1004
1004
  )
1005
1005
  if isinstance(iid, int):
1006
1006
  self.coords(iid, coords)
@@ -1353,11 +1353,9 @@ class RowIndex(tk.Canvas):
1353
1353
  # the left hand downward point
1354
1354
  x1 + 5 + indent,
1355
1355
  y1 + mid_y + small_mod,
1356
-
1357
1356
  # the middle upward point
1358
1357
  x1 + 5 + indent + small_mod + small_mod,
1359
1358
  y1 + mid_y - small_mod,
1360
-
1361
1359
  # the right hand downward point
1362
1360
  x1 + 5 + indent + small_mod + small_mod + small_mod + small_mod,
1363
1361
  y1 + mid_y + small_mod,
@@ -1368,11 +1366,9 @@ class RowIndex(tk.Canvas):
1368
1366
  # the upper point
1369
1367
  x1 + 5 + indent + small_mod + small_mod,
1370
1368
  y1 + mid_y - small_mod - small_mod,
1371
-
1372
1369
  # the middle point
1373
1370
  x1 + 5 + indent + small_mod + small_mod + small_mod + small_mod,
1374
1371
  y1 + mid_y,
1375
-
1376
1372
  # the bottom point
1377
1373
  x1 + 5 + indent + small_mod + small_mod,
1378
1374
  y1 + mid_y + small_mod + small_mod,
@@ -1418,21 +1414,21 @@ class RowIndex(tk.Canvas):
1418
1414
  if open_:
1419
1415
  # up arrow
1420
1416
  points = (
1421
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
1417
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
1422
1418
  y1 + mid_y + small_mod,
1423
- x2 - 3 - small_mod - small_mod,
1419
+ x2 - 4 - small_mod - small_mod,
1424
1420
  y1 + mid_y - small_mod,
1425
- x2 - 3,
1421
+ x2 - 4,
1426
1422
  y1 + mid_y + small_mod,
1427
1423
  )
1428
1424
  else:
1429
1425
  # down arrow
1430
1426
  points = (
1431
- x2 - 3 - small_mod - small_mod - small_mod - small_mod,
1427
+ x2 - 4 - small_mod - small_mod - small_mod - small_mod,
1432
1428
  y1 + mid_y - small_mod,
1433
- x2 - 3 - small_mod - small_mod,
1429
+ x2 - 4 - small_mod - small_mod,
1434
1430
  y1 + mid_y + small_mod,
1435
- x2 - 3,
1431
+ x2 - 4,
1436
1432
  y1 + mid_y - small_mod,
1437
1433
  )
1438
1434
  if self.hidd_dropdown:
@@ -1444,10 +1440,13 @@ class RowIndex(tk.Canvas):
1444
1440
  self.itemconfig(t, fill=fill, tag=tag, state="normal")
1445
1441
  self.lift(t)
1446
1442
  else:
1447
- t = self.create_polygon(
1443
+ t = self.create_line(
1448
1444
  points,
1449
1445
  fill=fill,
1450
1446
  tag=tag,
1447
+ width=2,
1448
+ capstyle=tk.ROUND,
1449
+ joinstyle=tk.BEVEL,
1451
1450
  )
1452
1451
  self.disp_dropdown[t] = True
1453
1452
 
tksheet/sheet.py CHANGED
@@ -10,7 +10,14 @@ from collections.abc import (
10
10
  Iterator,
11
11
  Sequence,
12
12
  )
13
- from itertools import accumulate, chain, islice, product, repeat
13
+ from itertools import (
14
+ accumulate,
15
+ chain,
16
+ filterfalse,
17
+ islice,
18
+ product,
19
+ repeat,
20
+ )
14
21
  from timeit import default_timer
15
22
  from tkinter import ttk
16
23
  from typing import Literal
@@ -3813,7 +3820,6 @@ class Sheet(tk.Frame):
3813
3820
  columns: None | Literal["all"] | Iterator[int] = None,
3814
3821
  all_columns_displayed: None | bool = None,
3815
3822
  reset_col_positions: bool = True,
3816
- refresh: bool = False,
3817
3823
  redraw: bool = False,
3818
3824
  deselect_all: bool = True,
3819
3825
  **kwargs,
@@ -3828,8 +3834,9 @@ class Sheet(tk.Frame):
3828
3834
  reset_col_positions=reset_col_positions,
3829
3835
  deselect_all=deselect_all,
3830
3836
  )
3831
- if refresh or redraw:
3832
- self.set_refresh_timer(redraw if redraw else refresh)
3837
+ if "refresh" in kwargs:
3838
+ redraw = kwargs["refresh"]
3839
+ self.set_refresh_timer(redraw)
3833
3840
  return res
3834
3841
 
3835
3842
  def hide_columns(
@@ -3846,7 +3853,7 @@ class Sheet(tk.Frame):
3846
3853
  if not columns:
3847
3854
  return
3848
3855
  if self.MT.all_columns_displayed:
3849
- self.MT.displayed_columns = [c for c in range(self.MT.total_data_cols()) if c not in columns]
3856
+ self.MT.displayed_columns = list(filterfalse(columns.__contains__, range(self.MT.total_data_cols())))
3850
3857
  to_pop = {c: c for c in columns}
3851
3858
  else:
3852
3859
  to_pop = {}
@@ -3876,13 +3883,18 @@ class Sheet(tk.Frame):
3876
3883
  self.MT.deselect(redraw=False)
3877
3884
  return self.set_refresh_timer(redraw)
3878
3885
 
3879
- # uses data indexes
3880
3886
  def show_columns(
3881
3887
  self,
3882
3888
  columns: int | Iterator[int],
3883
3889
  redraw: bool = True,
3884
3890
  deselect_all: bool = True,
3885
3891
  ) -> Sheet:
3892
+ """
3893
+ 'columns' argument must be data indexes
3894
+ Function will return without action if Sheet.all_columns
3895
+ """
3896
+ if self.MT.all_columns_displayed:
3897
+ return
3886
3898
  if isinstance(columns, int):
3887
3899
  columns = [columns]
3888
3900
  cws = self.MT.get_column_widths()
@@ -3908,7 +3920,10 @@ class Sheet(tk.Frame):
3908
3920
 
3909
3921
  @all_columns.setter
3910
3922
  def all_columns(self, a: bool) -> Sheet:
3911
- self.MT.all_columns_displayed = a
3923
+ self.MT.display_columns(
3924
+ columns=None,
3925
+ all_columns_displayed=a,
3926
+ )
3912
3927
  return self
3913
3928
 
3914
3929
  @property
@@ -3917,8 +3932,8 @@ class Sheet(tk.Frame):
3917
3932
 
3918
3933
  @displayed_columns.setter
3919
3934
  def displayed_columns(self, columns: list[int]) -> Sheet:
3920
- self.display_columns(columns=columns, reset_col_positions=False, redraw=True)
3921
- return self
3935
+ self.display_columns(columns=columns, reset_col_positions=True, redraw=False)
3936
+ return self.set_refresh_timer()
3922
3937
 
3923
3938
  # Hiding Rows
3924
3939
 
@@ -3933,7 +3948,6 @@ class Sheet(tk.Frame):
3933
3948
  rows: None | Literal["all"] | Iterator[int] = None,
3934
3949
  all_rows_displayed: None | bool = None,
3935
3950
  reset_row_positions: bool = True,
3936
- refresh: bool = False,
3937
3951
  redraw: bool = False,
3938
3952
  deselect_all: bool = True,
3939
3953
  **kwargs,
@@ -3946,8 +3960,9 @@ class Sheet(tk.Frame):
3946
3960
  reset_row_positions=reset_row_positions,
3947
3961
  deselect_all=deselect_all,
3948
3962
  )
3949
- if refresh or redraw:
3950
- self.set_refresh_timer(redraw if redraw else refresh)
3963
+ if "refresh" in kwargs:
3964
+ redraw = kwargs["refresh"]
3965
+ self.set_refresh_timer(redraw)
3951
3966
  return res
3952
3967
 
3953
3968
  def hide_rows(
@@ -3965,7 +3980,7 @@ class Sheet(tk.Frame):
3965
3980
  if not rows:
3966
3981
  return
3967
3982
  if self.MT.all_rows_displayed:
3968
- self.MT.displayed_rows = [r for r in range(self.MT.total_data_rows()) if r not in rows]
3983
+ self.MT.displayed_rows = list(filterfalse(rows.__contains__, range(self.MT.total_data_rows())))
3969
3984
  to_pop = {r: r for r in rows}
3970
3985
  else:
3971
3986
  to_pop = {}
@@ -3996,13 +4011,18 @@ class Sheet(tk.Frame):
3996
4011
  self.MT.deselect(redraw=False)
3997
4012
  return self.set_refresh_timer(redraw)
3998
4013
 
3999
- # uses data indexes
4000
4014
  def show_rows(
4001
4015
  self,
4002
4016
  rows: int | Iterator[int],
4003
4017
  redraw: bool = True,
4004
4018
  deselect_all: bool = True,
4005
4019
  ) -> Sheet:
4020
+ """
4021
+ 'rows' argument must be data indexes
4022
+ Function will return without action if Sheet.all_rows
4023
+ """
4024
+ if self.MT.all_rows_displayed:
4025
+ return
4006
4026
  if isinstance(rows, int):
4007
4027
  rows = [rows]
4008
4028
  rhs = self.MT.get_row_heights()
@@ -4028,7 +4048,10 @@ class Sheet(tk.Frame):
4028
4048
 
4029
4049
  @all_rows.setter
4030
4050
  def all_rows(self, a: bool) -> Sheet:
4031
- self.MT.all_rows_displayed = a
4051
+ self.MT.display_rows(
4052
+ rows=None,
4053
+ all_rows_displayed=a,
4054
+ )
4032
4055
  return self
4033
4056
 
4034
4057
  @property
@@ -4037,8 +4060,8 @@ class Sheet(tk.Frame):
4037
4060
 
4038
4061
  @displayed_rows.setter
4039
4062
  def displayed_rows(self, rows: list[int]) -> Sheet:
4040
- self.display_rows(rows=rows, reset_row_positions=False, redraw=True)
4041
- return self
4063
+ self.display_rows(rows=rows, reset_row_positions=True, redraw=False)
4064
+ return self.set_refresh_timer()
4042
4065
 
4043
4066
  # Hiding Sheet Elements
4044
4067
 
@@ -4747,7 +4770,7 @@ class Sheet(tk.Frame):
4747
4770
  Closes everything else
4748
4771
  """
4749
4772
  self.hide_rows(
4750
- set(rn for rn in self.MT.displayed_rows if self.MT._row_index[rn].parent),
4773
+ rows={rn for rn in self.MT.displayed_rows if self.MT._row_index[rn].parent},
4751
4774
  redraw=False,
4752
4775
  deselect_all=False,
4753
4776
  data_indexes=True,
@@ -4768,13 +4791,15 @@ class Sheet(tk.Frame):
4768
4791
  """
4769
4792
  to_open = []
4770
4793
  disp_set = set(self.MT.displayed_rows)
4771
- quick_rns = self.RI.tree_rns
4772
- quick_open_ids = self.RI.tree_open_ids
4794
+ tree = self.RI.tree
4795
+ rns = self.RI.tree_rns
4796
+ open_ids = self.RI.tree_open_ids
4797
+ descendants = self.RI.get_iid_descendants
4773
4798
  for item in filter(items.__contains__, self.get_children()):
4774
- if self.RI.tree[item].children:
4775
- quick_open_ids.add(item)
4776
- if quick_rns[item] in disp_set:
4777
- to_disp = [quick_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True)]
4799
+ if tree[item].children:
4800
+ open_ids.add(item)
4801
+ if rns[item] in disp_set:
4802
+ to_disp = [rns[did] for did in descendants(item, check_open=True)]
4778
4803
  for i in to_disp:
4779
4804
  disp_set.add(i)
4780
4805
  to_open.extend(to_disp)
@@ -4921,7 +4946,7 @@ class Sheet(tk.Frame):
4921
4946
  self.RI.tree_open_ids.add(item)
4922
4947
  if self.item_displayed(item):
4923
4948
  self.show_rows(
4924
- rows=(self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True)),
4949
+ rows=map(self.RI.tree_rns.__getitem__, self.RI.get_iid_descendants(item, check_open=True)),
4925
4950
  redraw=False,
4926
4951
  deselect_all=False,
4927
4952
  )
@@ -4929,7 +4954,9 @@ class Sheet(tk.Frame):
4929
4954
  self.RI.tree_open_ids.discard(item)
4930
4955
  if self.item_displayed(item):
4931
4956
  self.hide_rows(
4932
- rows={self.RI.tree_rns[did] for did in self.RI.get_iid_descendants(item, check_open=True)},
4957
+ rows=set(
4958
+ map(self.RI.tree_rns.__getitem__, self.RI.get_iid_descendants(item, check_open=True))
4959
+ ),
4933
4960
  redraw=False,
4934
4961
  deselect_all=False,
4935
4962
  data_indexes=True,
@@ -5106,7 +5133,8 @@ class Sheet(tk.Frame):
5106
5133
  if (item := item.lower()) not in self.RI.tree:
5107
5134
  raise ValueError(f"Item '{item}' does not exist.")
5108
5135
  if not self.RI.tree[item].parent:
5109
- return next(index for index, node in enumerate(self.RI.gen_top_nodes()) if node == self.RI.tree[item])
5136
+ find_node = self.RI.tree[item]
5137
+ return next(index for index, node in enumerate(self.RI.gen_top_nodes()) if node == find_node)
5110
5138
  return self.RI.tree[item].parent.children.index(self.RI.tree[item])
5111
5139
 
5112
5140
  def item_displayed(self, item: str) -> bool:
@@ -5128,8 +5156,11 @@ class Sheet(tk.Frame):
5128
5156
  if (item := item.lower()) not in self.RI.tree:
5129
5157
  raise ValueError(f"Item '{item}' does not exist.")
5130
5158
  if self.RI.tree[item].parent:
5131
- for iid in self.RI.get_iid_ancestors(item):
5132
- self.item(iid, open_=True, redraw=False)
5159
+ self.show_rows(
5160
+ rows=self._tree_open(list(self.RI.get_iid_ancestors(item))),
5161
+ redraw=False,
5162
+ deselect_all=False,
5163
+ )
5133
5164
  return self.set_refresh_timer(redraw)
5134
5165
 
5135
5166
  def scroll_to_item(self, item: str, redraw=False) -> Sheet:
@@ -5151,14 +5182,15 @@ class Sheet(tk.Frame):
5151
5182
  Get currently selected item ids
5152
5183
  """
5153
5184
  return [
5154
- self.MT._row_index[self.displayed_row_to_data(rn)].iid
5155
- for rn in self.get_selected_rows(get_cells_as_rows=cells)
5185
+ self.MT._row_index[self.MT.displayed_rows[rn]].iid for rn in self.get_selected_rows(get_cells_as_rows=cells)
5156
5186
  ]
5157
5187
 
5158
5188
  def selection_set(self, *items, redraw: bool = True) -> Sheet:
5159
5189
  if any(item.lower() in self.RI.tree for item in unpack(items)):
5160
- self.deselect(redraw=False)
5190
+ boxes_to_hide = tuple(self.MT.selection_boxes)
5161
5191
  self.selection_add(*items, redraw=False)
5192
+ for iid in boxes_to_hide:
5193
+ self.MT.hide_selection_box(iid)
5162
5194
  return self.set_refresh_timer(redraw)
5163
5195
 
5164
5196
  def selection_add(self, *items, redraw: bool = True) -> Sheet:
@@ -5220,7 +5252,7 @@ class Sheet(tk.Frame):
5220
5252
 
5221
5253
  # Functions not in docs
5222
5254
 
5223
- def event_generate(self, *args, **kwargs):
5255
+ def event_generate(self, *args, **kwargs) -> None:
5224
5256
  self.MT.event_generate(*args, **kwargs)
5225
5257
 
5226
5258
  def emit_event(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.2.8
3
+ Version: 7.2.9
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
@@ -0,0 +1,20 @@
1
+ tksheet/__init__.py,sha256=CsvPUSqncRztCcOp7ke7wcU9HI6vtZhS7NdDrltgRyU,2144
2
+ tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
+ tksheet/column_headers.py,sha256=HlMCcwEz2e2L7j93mpkhtlXbIMu_yRTWFIXr9f1Sch8,102430
4
+ tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
+ tksheet/functions.py,sha256=PgigHSO_cnQoWSXFSfJ5YlPbyOVd2BYUHU4UBbUCCFE,40706
6
+ tksheet/main_table.py,sha256=4jdk2ro5pyooMr_BKiv2PkS-sxnWLZe0HcgX69NH7Y8,328195
7
+ tksheet/other_classes.py,sha256=CDN38ZjKxZro9YOS_g0DjMC82-Mi9udedny4wdd90W0,14347
8
+ tksheet/row_index.py,sha256=to6EPvmh7NV9YjGfrLOYgrMqDiSMdTjwOWa6Umh0_wA,109206
9
+ tksheet/sheet.py,sha256=d3HnnJeaEkhZ7ID2t8M2g87hLg66iJmUWV60rGz_OaY,273221
10
+ tksheet/sheet_options.py,sha256=Azo7_-H0e0ssYEoU7Mq_OWy3S-U05rp4_6Q2E2Ffuu8,12262
11
+ tksheet/text_editor.py,sha256=aRm1Y5GfORiEAJthtN1uQ30CT3VoF8mRWvR-SIXPrJU,6548
12
+ tksheet/themes.py,sha256=ijEG5xsrNZR04r5aZaVDHO9_ZFW5q6bzw6NxIjkKIR4,14474
13
+ tksheet/top_left_rectangle.py,sha256=ZptxpfkkYL09d6ILDkY_u6RLv8PB-AGHOkBz-K0mJ0E,8473
14
+ tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
+ tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
+ tksheet-7.2.9.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
+ tksheet-7.2.9.dist-info/METADATA,sha256=sNAOmKjkUJ-PKgZ7koeO3rqc0-cJn5_ppeXXDjpJdJ4,6284
18
+ tksheet-7.2.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ tksheet-7.2.9.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
+ tksheet-7.2.9.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- tksheet/__init__.py,sha256=9-NobW_uQoFNiHMsm3ygSmFmUWnPmuzPDlGokMzQ3rQ,2144
2
- tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
- tksheet/column_headers.py,sha256=hnrms1OqpHDSYS82x64nXIM8tdgDIBCvdB3c1l7B79s,102351
4
- tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
- tksheet/functions.py,sha256=Ie53z5GWbGoUXUiTf0DtoyOadWFbMFXMFwUjM67vetI,40706
6
- tksheet/main_table.py,sha256=NiKliH0tKW2mTyDXhqAJ0cDiBXcN36lL8EhwGDiZd5U,327622
7
- tksheet/other_classes.py,sha256=CDN38ZjKxZro9YOS_g0DjMC82-Mi9udedny4wdd90W0,14347
8
- tksheet/row_index.py,sha256=6cQgRyzIBZbDHJUSU9sAoakkgrZYghq8n404r67Yq-c,109185
9
- tksheet/sheet.py,sha256=xMctRdAC9npUPPEMXFfH4qCE_vyrUV7BJFrCumaOmU0,272368
10
- tksheet/sheet_options.py,sha256=Azo7_-H0e0ssYEoU7Mq_OWy3S-U05rp4_6Q2E2Ffuu8,12262
11
- tksheet/text_editor.py,sha256=aRm1Y5GfORiEAJthtN1uQ30CT3VoF8mRWvR-SIXPrJU,6548
12
- tksheet/themes.py,sha256=ijEG5xsrNZR04r5aZaVDHO9_ZFW5q6bzw6NxIjkKIR4,14474
13
- tksheet/top_left_rectangle.py,sha256=ZptxpfkkYL09d6ILDkY_u6RLv8PB-AGHOkBz-K0mJ0E,8473
14
- tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
- tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
- tksheet-7.2.8.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
- tksheet-7.2.8.dist-info/METADATA,sha256=FsNwrdIu6DZKJpGMsPBN4YvdHR9Y12LHqxvG9d7f3z4,6284
18
- tksheet-7.2.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- tksheet-7.2.8.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
- tksheet-7.2.8.dist-info/RECORD,,