tksheet 7.2.2__py3-none-any.whl → 7.2.4__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.2"
7
+ __version__ = "7.2.4"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
tksheet/column_headers.py CHANGED
@@ -1440,7 +1440,7 @@ class ColumnHeaders(tk.Canvas):
1440
1440
  ]
1441
1441
  for c in range(grid_start_col, grid_end_col):
1442
1442
  draw_x = self.MT.col_positions[c]
1443
- if self.width_resizing_enabled:
1443
+ if c and self.width_resizing_enabled:
1444
1444
  self.visible_col_dividers[c] = (draw_x - 2, 1, draw_x + 2, yend)
1445
1445
  points.extend(
1446
1446
  (
tksheet/main_table.py CHANGED
@@ -84,6 +84,7 @@ from .other_classes import (
84
84
  EventDataDict,
85
85
  FontTuple,
86
86
  Loc,
87
+ ProgressBar,
87
88
  Selected,
88
89
  SelectionBox,
89
90
  TextEditorStorage,
@@ -165,6 +166,7 @@ class MainTable(tk.Canvas):
165
166
  self.col_options = {}
166
167
  self.row_options = {}
167
168
  self.purge_undo_and_redo_stack()
169
+ self.progress_bars = {}
168
170
 
169
171
  self.extra_table_rc_menu_funcs = {}
170
172
  self.extra_index_rc_menu_funcs = {}
@@ -852,6 +854,7 @@ class MainTable(tk.Canvas):
852
854
  index=index,
853
855
  row_heights=row_heights,
854
856
  event_data=event_data,
857
+ mod_event_boxes=False,
855
858
  )
856
859
  if added_cols:
857
860
  ctr = 0
@@ -901,10 +904,8 @@ class MainTable(tk.Canvas):
901
904
  header=headers,
902
905
  column_widths=column_widths,
903
906
  event_data=event_data,
907
+ mod_event_boxes=False,
904
908
  )
905
- self.deselect("all", redraw=False)
906
- if event_data["cells"]["table"] or event_data["added"]["rows"] or event_data["added"]["columns"]:
907
- self.undo_stack.append(pickled_event_dict(event_data))
908
909
  if added_rows:
909
910
  selboxr = selected_r + new_data_numrows
910
911
  else:
@@ -913,6 +914,7 @@ class MainTable(tk.Canvas):
913
914
  selboxc = selected_c + new_data_numcols
914
915
  else:
915
916
  selboxc = selected_c_adjusted_new_data_numcols
917
+ self.deselect("all", redraw=False)
916
918
  self.create_selection_box(
917
919
  selected_r,
918
920
  selected_c,
@@ -921,6 +923,10 @@ class MainTable(tk.Canvas):
921
923
  "cells",
922
924
  run_binding=True,
923
925
  )
926
+ event_data["selection_boxes"] = self.get_boxes()
927
+ event_data["selected"] = self.selected
928
+ if event_data["cells"]["table"] or event_data["added"]["rows"] or event_data["added"]["columns"]:
929
+ self.undo_stack.append(pickled_event_dict(event_data))
924
930
  self.see(
925
931
  r=selected_r,
926
932
  c=selected_c,
@@ -1098,6 +1104,7 @@ class MainTable(tk.Canvas):
1098
1104
  tags: {(k[0], full_new_idxs[k[1]]) for k in tagged} for tags, tagged in self.tagged_cells.items()
1099
1105
  }
1100
1106
  self.cell_options = {(k[0], full_new_idxs[k[1]]): v for k, v in self.cell_options.items()}
1107
+ self.progress_bars = {(k[0], full_new_idxs[k[1]]): v for k, v in self.progress_bars.items()}
1101
1108
  self.col_options = {full_new_idxs[k]: v for k, v in self.col_options.items()}
1102
1109
  self.tagged_columns = {
1103
1110
  tags: {full_new_idxs[k] for k in tagged} for tags, tagged in self.tagged_columns.items()
@@ -1337,6 +1344,7 @@ class MainTable(tk.Canvas):
1337
1344
  tags: {(full_new_idxs[k[0]], k[1]) for k in tagged} for tags, tagged in self.tagged_cells.items()
1338
1345
  }
1339
1346
  self.cell_options = {(full_new_idxs[k[0]], k[1]): v for k, v in self.cell_options.items()}
1347
+ self.progress_bars = {(full_new_idxs[k[0]], k[1]): v for k, v in self.progress_bars.items()}
1340
1348
  self.tagged_rows = {tags: {full_new_idxs[k] for k in tagged} for tags, tagged in self.tagged_rows.items()}
1341
1349
  self.row_options = {full_new_idxs[k]: v for k, v in self.row_options.items()}
1342
1350
  self.RI.cell_options = {full_new_idxs[k]: v for k, v in self.RI.cell_options.items()}
@@ -1561,7 +1569,6 @@ class MainTable(tk.Canvas):
1561
1569
  event_data["selection_boxes"] = modification["selection_boxes"]
1562
1570
  event_data["selected"] = modification["selected"]
1563
1571
  saved_cells = False
1564
-
1565
1572
  if modification["added"]["rows"] or modification["added"]["columns"]:
1566
1573
  event_data = self.save_cells_using_modification(modification, event_data)
1567
1574
  saved_cells = True
@@ -1627,11 +1634,6 @@ class MainTable(tk.Canvas):
1627
1634
  event_data=event_data,
1628
1635
  )
1629
1636
  self.displayed_rows = modification["added"]["rows"]["displayed_rows"]
1630
- if len(self.row_positions) > 1:
1631
- self.reselect_from_get_boxes(
1632
- modification["selection_boxes"],
1633
- modification["selected"],
1634
- )
1635
1637
 
1636
1638
  if modification["added"]["columns"]:
1637
1639
  self.deselect("all", run_binding=False, redraw=False)
@@ -1644,13 +1646,8 @@ class MainTable(tk.Canvas):
1644
1646
  event_data=event_data,
1645
1647
  )
1646
1648
  self.displayed_columns = modification["added"]["columns"]["displayed_columns"]
1647
- if len(self.col_positions) > 1:
1648
- self.reselect_from_get_boxes(
1649
- modification["selection_boxes"],
1650
- modification["selected"],
1651
- )
1652
1649
 
1653
- if modification["deleted"]["rows"]:
1650
+ if modification["deleted"]["rows"] or modification["deleted"]["row_heights"]:
1654
1651
  self.add_rows(
1655
1652
  rows=modification["deleted"]["rows"],
1656
1653
  index=modification["deleted"]["index"],
@@ -1663,7 +1660,7 @@ class MainTable(tk.Canvas):
1663
1660
  )
1664
1661
  self.restore_options_named_spans(modification)
1665
1662
 
1666
- if modification["deleted"]["columns"]:
1663
+ if modification["deleted"]["columns"] or modification["deleted"]["column_widths"]:
1667
1664
  self.add_columns(
1668
1665
  columns=modification["deleted"]["columns"],
1669
1666
  header=modification["deleted"]["header"],
@@ -1676,27 +1673,10 @@ class MainTable(tk.Canvas):
1676
1673
  )
1677
1674
  self.restore_options_named_spans(modification)
1678
1675
 
1679
- if modification["eventname"].startswith("edit") and (
1680
- modification["deleted"]["columns"] or modification["deleted"]["rows"]
1681
- ):
1682
- self.reselect_from_get_boxes(
1683
- modification["selection_boxes"],
1684
- modification["selected"],
1685
- )
1686
-
1687
1676
  if modification["eventname"].startswith(("edit", "move")):
1688
1677
  if not saved_cells:
1689
1678
  event_data = self.save_cells_using_modification(modification, event_data)
1690
1679
  event_data = self.edit_cells_using_modification(modification, event_data)
1691
- if (
1692
- not modification["deleted"]["columns"]
1693
- and not modification["deleted"]["rows"]
1694
- and not modification["eventname"].startswith("move")
1695
- ):
1696
- self.reselect_from_get_boxes(
1697
- modification["selection_boxes"],
1698
- modification["selected"],
1699
- )
1700
1680
 
1701
1681
  elif modification["eventname"].startswith("add"):
1702
1682
  event_data["eventname"] = modification["eventname"].replace("add", "delete")
@@ -1704,6 +1684,15 @@ class MainTable(tk.Canvas):
1704
1684
  elif modification["eventname"].startswith("delete"):
1705
1685
  event_data["eventname"] = modification["eventname"].replace("delete", "add")
1706
1686
 
1687
+ if not modification["eventname"].startswith("move") and (
1688
+ len(self.row_positions) > 1 or len(self.col_positions) > 1
1689
+ ):
1690
+ self.deselect("all", redraw=False)
1691
+ self.reselect_from_get_boxes(
1692
+ modification["selection_boxes"],
1693
+ modification["selected"],
1694
+ )
1695
+
1707
1696
  if self.selected:
1708
1697
  self.see(
1709
1698
  r=self.selected.row,
@@ -3749,9 +3738,10 @@ class MainTable(tk.Canvas):
3749
3738
  for datacn in itercols:
3750
3739
  if (hw := self.CH.get_cell_dimensions(datacn)[0]) > w:
3751
3740
  w = hw
3741
+ else:
3742
+ w = min_column_width
3752
3743
  for datarn in iterrows:
3753
- txt = self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True)
3754
- if txt:
3744
+ if txt := self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True):
3755
3745
  qconf(qtxtm, text=txt, font=qfont)
3756
3746
  b = qbbox(qtxtm)
3757
3747
  tw = b[2] - b[0] + added_w_space
@@ -3995,6 +3985,9 @@ class MainTable(tk.Canvas):
3995
3985
  self.cell_options = {
3996
3986
  (r, c if not (num := bisect_right(cols, c)) else c + num): v for (r, c), v in self.cell_options.items()
3997
3987
  }
3988
+ self.progress_bars = {
3989
+ (r, c if not (num := bisect_right(cols, c)) else c + num): v for (r, c), v in self.progress_bars.items()
3990
+ }
3998
3991
  self.tagged_columns = {
3999
3992
  tags: {c if not (num := bisect_right(cols, c)) else c + num for c in tagged}
4000
3993
  for tags, tagged in self.tagged_columns.items()
@@ -4064,6 +4057,9 @@ class MainTable(tk.Canvas):
4064
4057
  self.cell_options = {
4065
4058
  (r if not (num := bisect_right(rows, r)) else r + num, c): v for (r, c), v in self.cell_options.items()
4066
4059
  }
4060
+ self.progress_bars = {
4061
+ (r if not (num := bisect_right(rows, r)) else r + num, c): v for (r, c), v in self.progress_bars.items()
4062
+ }
4067
4063
  self.tagged_rows = {
4068
4064
  tags: {r if not (num := bisect_right(rows, r)) else r + num for r in tagged}
4069
4065
  for tags, tagged in self.tagged_rows.items()
@@ -4153,6 +4149,14 @@ class MainTable(tk.Canvas):
4153
4149
  for (r, c), v in self.cell_options.items()
4154
4150
  if c not in to_del
4155
4151
  }
4152
+ self.progress_bars = {
4153
+ (
4154
+ r,
4155
+ c if not (num := bisect_left(to_bis, c)) else c - num,
4156
+ ): v
4157
+ for (r, c), v in self.progress_bars.items()
4158
+ if c not in to_del
4159
+ }
4156
4160
  self.tagged_columns = {
4157
4161
  tags: {c if not (num := bisect_left(to_bis, c)) else c - num for c in tagged if c not in to_del}
4158
4162
  for tags, tagged in self.tagged_columns.items()
@@ -4233,6 +4237,14 @@ class MainTable(tk.Canvas):
4233
4237
  for (r, c), v in self.cell_options.items()
4234
4238
  if r not in to_del
4235
4239
  }
4240
+ self.progress_bars = {
4241
+ (
4242
+ r if not (num := bisect_left(to_bis, r)) else r - num,
4243
+ c,
4244
+ ): v
4245
+ for (r, c), v in self.progress_bars.items()
4246
+ if r not in to_del
4247
+ }
4236
4248
  self.tagged_rows = {
4237
4249
  tags: {r if not (num := bisect_left(to_bis, r)) else r - num for r in tagged if r not in to_del}
4238
4250
  for tags, tagged in self.tagged_rows.items()
@@ -4300,6 +4312,7 @@ class MainTable(tk.Canvas):
4300
4312
  create_selections: bool = True,
4301
4313
  add_row_positions: bool = True,
4302
4314
  push_ops: bool = True,
4315
+ mod_event_boxes: bool = True,
4303
4316
  ) -> EventDataDict:
4304
4317
  self.saved_column_widths = {}
4305
4318
  saved_displayed_columns = list(self.displayed_columns)
@@ -4330,18 +4343,26 @@ class MainTable(tk.Canvas):
4330
4343
  maxrn = 0
4331
4344
  for cn, rowdict in reversed(columns.items()):
4332
4345
  for rn, v in rowdict.items():
4333
- if rn >= len(self.data):
4346
+ if rn < len(self.data) and cn > len(self.data[rn]):
4347
+ self.fix_row_len(rn, cn - 1)
4348
+ elif rn >= len(self.data):
4334
4349
  self.fix_data_len(rn, cn - 1)
4335
4350
  if rn > maxrn:
4336
4351
  maxrn = rn
4337
4352
  self.data[rn].insert(cn, v)
4338
4353
  # if not hiding rows then we can extend row positions if necessary
4339
- if add_row_positions and self.all_rows_displayed and maxrn + 1 > len(self.row_positions) - 1:
4340
- default_row_height = self.get_default_row_height()
4354
+ if add_row_positions and self.all_rows_displayed and maxrn >= len(self.row_positions) - 1:
4355
+ default_height = self.get_default_row_height()
4356
+ event_data["added"]["rows"] = {
4357
+ "table": {},
4358
+ "index": {},
4359
+ "row_heights": {rn: default_height for rn in range(len(self.row_positions) - 1, maxrn + 1)},
4360
+ "displayed_rows": self.displayed_rows,
4361
+ }
4341
4362
  self.set_row_positions(
4342
4363
  itr=chain(
4343
4364
  self.gen_row_heights(),
4344
- repeat(default_row_height, len(self.row_positions) - 1, maxrn + 1),
4365
+ repeat(default_height, maxrn + 1 - (len(self.row_positions) - 1)),
4345
4366
  )
4346
4367
  )
4347
4368
  if isinstance(self._headers, list) and header:
@@ -4362,6 +4383,9 @@ class MainTable(tk.Canvas):
4362
4383
  "columns",
4363
4384
  run_binding=True,
4364
4385
  )
4386
+ if mod_event_boxes:
4387
+ event_data["selection_boxes"] = self.get_boxes()
4388
+ event_data["selected"] = self.selected
4365
4389
  event_data["added"]["columns"] = {
4366
4390
  "table": columns,
4367
4391
  "header": header,
@@ -4433,6 +4457,7 @@ class MainTable(tk.Canvas):
4433
4457
  create_selections: bool = True,
4434
4458
  add_col_positions: bool = True,
4435
4459
  push_ops: bool = True,
4460
+ mod_event_boxes: bool = True,
4436
4461
  ) -> EventDataDict:
4437
4462
  self.saved_row_heights = {}
4438
4463
  saved_displayed_rows = list(self.displayed_rows)
@@ -4472,11 +4497,18 @@ class MainTable(tk.Canvas):
4472
4497
  if isinstance(self._row_index, list) and index:
4473
4498
  self._row_index = insert_items(self._row_index, index, self.RI.fix_index)
4474
4499
  # if not hiding columns then we can extend col positions if necessary
4475
- if add_col_positions and self.all_columns_displayed and maxcn + 1 > len(self.col_positions) - 1:
4500
+ if add_col_positions and self.all_columns_displayed and maxcn >= len(self.col_positions) - 1:
4501
+ default_width = self.PAR.ops.default_column_width
4502
+ event_data["added"]["columns"] = {
4503
+ "table": {},
4504
+ "header": {},
4505
+ "column_widths": {cn: default_width for cn in range(len(self.col_positions) - 1, maxcn + 1)},
4506
+ "displayed_columns": self.displayed_columns,
4507
+ }
4476
4508
  self.set_col_positions(
4477
4509
  itr=chain(
4478
4510
  self.gen_column_widths(),
4479
- repeat(self.PAR.ops.default_column_width, len(self.col_positions) - 1, maxcn + 1),
4511
+ repeat(default_width, maxcn + 1 - (len(self.col_positions) - 1)),
4480
4512
  )
4481
4513
  )
4482
4514
  if push_ops:
@@ -4495,6 +4527,9 @@ class MainTable(tk.Canvas):
4495
4527
  "rows",
4496
4528
  run_binding=True,
4497
4529
  )
4530
+ if mod_event_boxes:
4531
+ event_data["selection_boxes"] = self.get_boxes()
4532
+ event_data["selected"] = self.selected
4498
4533
  event_data["added"]["rows"] = {
4499
4534
  "table": rows,
4500
4535
  "index": index,
@@ -5050,7 +5085,10 @@ class MainTable(tk.Canvas):
5050
5085
  can_width: int | None,
5051
5086
  ) -> str:
5052
5087
  redrawn = False
5053
- kwargs = self.get_cell_kwargs(datarn, datacn, key="highlight")
5088
+ if (datarn, datacn) in self.progress_bars:
5089
+ kwargs = self.progress_bars[(datarn, datacn)]
5090
+ else:
5091
+ kwargs = self.get_cell_kwargs(datarn, datacn, key="highlight")
5054
5092
  if kwargs:
5055
5093
  if kwargs[0] is not None:
5056
5094
  c_1 = kwargs[0] if kwargs[0].startswith("#") else color_map[kwargs[0]]
@@ -5095,11 +5133,12 @@ class MainTable(tk.Canvas):
5095
5133
  if kwargs[0] is not None:
5096
5134
  fill = kwargs[0]
5097
5135
  if kwargs[0] is not None:
5098
- redrawn = self.redraw_highlight(
5099
- fc + 1,
5100
- fr + 1,
5101
- sc,
5102
- sr,
5136
+ highlight_fn = partial(
5137
+ self.redraw_highlight,
5138
+ x1=fc + 1,
5139
+ y1=fr + 1,
5140
+ x2=sc,
5141
+ y2=sr,
5103
5142
  fill=fill,
5104
5143
  outline=(
5105
5144
  self.PAR.ops.table_fg
@@ -5107,8 +5146,20 @@ class MainTable(tk.Canvas):
5107
5146
  else ""
5108
5147
  ),
5109
5148
  tag="hi",
5110
- can_width=can_width if (len(kwargs) > 2 and kwargs[2]) else None,
5111
5149
  )
5150
+ if isinstance(kwargs, ProgressBar):
5151
+ if kwargs.del_when_done and kwargs.percent >= 100:
5152
+ del self.progress_bars[(datarn, datacn)]
5153
+ else:
5154
+ redrawn = highlight_fn(
5155
+ can_width=None,
5156
+ pc=kwargs.percent,
5157
+ )
5158
+ else:
5159
+ redrawn = highlight_fn(
5160
+ can_width=can_width if (len(kwargs) > 2 and kwargs[2]) else None,
5161
+ pc=None,
5162
+ )
5112
5163
  elif not kwargs:
5113
5164
  if "cells" in selections and (r, c) in selections["cells"]:
5114
5165
  tf = self.PAR.ops.table_selected_cells_fg
@@ -5121,13 +5172,15 @@ class MainTable(tk.Canvas):
5121
5172
  return tf, redrawn
5122
5173
 
5123
5174
  def redraw_highlight(self, x1, y1, x2, y2, fill, outline, tag, can_width=None, pc=None):
5124
- if not is_type_int(pc) or pc >= 100 or pc <= 0:
5175
+ if not is_type_int(pc) or pc >= 100:
5125
5176
  coords = (
5126
5177
  x1 - 1 if outline else x1,
5127
5178
  y1 - 1 if outline else y1,
5128
5179
  x2 if can_width is None else x2 + can_width,
5129
5180
  y2,
5130
5181
  )
5182
+ elif pc <= 0:
5183
+ coords = (x1, y1, x1, y2)
5131
5184
  else:
5132
5185
  coords = (x1, y1, (x2 - x1) * (pc / 100), y2)
5133
5186
  if self.hidd_high:
@@ -5340,18 +5393,21 @@ class MainTable(tk.Canvas):
5340
5393
  if i not in diffs:
5341
5394
  heights[i] -= change
5342
5395
  self.row_positions = list(accumulate(chain([0], heights)))
5343
- if self.PAR.ops.auto_resize_row_index is not True:
5344
- if can_width >= self.col_positions[-1] + self.PAR.ops.empty_horizontal and self.PAR.xscroll_showing:
5345
- self.PAR.xscroll.grid_forget()
5346
- self.PAR.xscroll_showing = False
5347
- elif (
5348
- can_width < self.col_positions[-1] + self.PAR.ops.empty_horizontal
5349
- and not self.PAR.xscroll_showing
5350
- and not self.PAR.xscroll_disabled
5351
- and can_height > 40
5352
- ):
5353
- self.PAR.xscroll.grid(row=2, column=0, columnspan=2, sticky="nswe")
5354
- self.PAR.xscroll_showing = True
5396
+ if (
5397
+ self.PAR.ops.auto_resize_row_index is not True
5398
+ and can_width >= self.col_positions[-1] + self.PAR.ops.empty_horizontal
5399
+ and self.PAR.xscroll_showing
5400
+ ):
5401
+ self.PAR.xscroll.grid_forget()
5402
+ self.PAR.xscroll_showing = False
5403
+ elif (
5404
+ can_width < self.col_positions[-1] + self.PAR.ops.empty_horizontal
5405
+ and not self.PAR.xscroll_showing
5406
+ and not self.PAR.xscroll_disabled
5407
+ and can_height > 40
5408
+ ):
5409
+ self.PAR.xscroll.grid(row=2, column=0, columnspan=2, sticky="nswe")
5410
+ self.PAR.xscroll_showing = True
5355
5411
  if can_height >= self.row_positions[-1] + self.PAR.ops.empty_vertical and self.PAR.yscroll_showing:
5356
5412
  self.PAR.yscroll.grid_forget()
5357
5413
  self.PAR.yscroll_showing = False
@@ -5829,7 +5885,8 @@ class MainTable(tk.Canvas):
5829
5885
  )
5830
5886
  return
5831
5887
  # wasn't provided an item and couldn't find a box at coords so select cell
5832
- self.select_cell(r, c, redraw=True)
5888
+ if r < len(self.row_positions) - 1 and c < len(self.col_positions) - 1:
5889
+ self.select_cell(r, c, redraw=True)
5833
5890
 
5834
5891
  def set_current_to_last(self) -> None:
5835
5892
  if self.selection_boxes:
tksheet/other_classes.py CHANGED
@@ -36,7 +36,6 @@ Highlight = namedtuple(
36
36
  DrawnItem = namedtuple("DrawnItem", "iid showing")
37
37
  TextCfg = namedtuple("TextCfg", "txt tf font align")
38
38
  DraggedRowColumn = namedtuple("DraggedRowColumn", "dragged to_move")
39
- ProgressBar = namedtuple("ProgressBar", "bg fg pc name")
40
39
 
41
40
 
42
41
  def num2alpha(n: int) -> str | None:
@@ -470,3 +469,31 @@ Selected = namedtuple(
470
469
  None,
471
470
  ),
472
471
  )
472
+
473
+
474
+ class ProgressBar:
475
+ __slots__ = ("bg", "fg", "name", "percent", "del_when_done")
476
+
477
+ def __init__(self, bg: str, fg: str, name: Hashable, percent: int, del_when_done: bool) -> None:
478
+ self.bg = bg
479
+ self.fg = fg
480
+ self.name = name
481
+ self.percent = percent
482
+ self.del_when_done = del_when_done
483
+
484
+ def __len__(self):
485
+ return 2
486
+
487
+ def __getitem__(self, key: Hashable) -> object:
488
+ if key == 0:
489
+ return self.bg
490
+ elif key == 1:
491
+ return self.fg
492
+ elif key == 2:
493
+ return self.name
494
+ elif key == 3:
495
+ return self.percent
496
+ elif key == 4:
497
+ return self.del_when_done
498
+ else:
499
+ return self.__getattribute__(key)
tksheet/row_index.py CHANGED
@@ -1539,7 +1539,7 @@ class RowIndex(tk.Canvas):
1539
1539
  ]
1540
1540
  for r in range(grid_start_row, grid_end_row):
1541
1541
  draw_y = self.MT.row_positions[r]
1542
- if self.height_resizing_enabled:
1542
+ if r and self.height_resizing_enabled:
1543
1543
  self.visible_row_dividers[r] = (1, draw_y - 2, xend, draw_y + 2)
1544
1544
  points.extend(
1545
1545
  (
tksheet/sheet.py CHANGED
@@ -3,7 +3,13 @@ from __future__ import annotations
3
3
  import tkinter as tk
4
4
  from bisect import bisect_left
5
5
  from collections import defaultdict, deque
6
- from collections.abc import Callable, Generator, Iterator, Sequence
6
+ from collections.abc import (
7
+ Callable,
8
+ Generator,
9
+ Hashable,
10
+ Iterator,
11
+ Sequence,
12
+ )
7
13
  from itertools import accumulate, chain, islice, product, repeat
8
14
  from timeit import default_timer
9
15
  from tkinter import ttk
@@ -47,6 +53,7 @@ from .other_classes import (
47
53
  FontTuple,
48
54
  GeneratedMouseEvent,
49
55
  Node,
56
+ ProgressBar,
50
57
  Selected,
51
58
  SelectionBox,
52
59
  Span,
@@ -1503,6 +1510,7 @@ class Sheet(tk.Frame):
1503
1510
  self.MT.deselect(redraw=False)
1504
1511
  if sheet_options:
1505
1512
  self.ops = new_sheet_options()
1513
+ self.change_theme(redraw=False)
1506
1514
  if tree:
1507
1515
  self.RI.tree_reset()
1508
1516
  if tree or row_heights or column_widths:
@@ -4291,6 +4299,9 @@ class Sheet(tk.Frame):
4291
4299
  if any(k in kwargs for k in scrollbar_options_keys):
4292
4300
  self.set_scrollbar_options()
4293
4301
  self.MT.create_rc_menus()
4302
+ if "treeview" in kwargs:
4303
+ self.set_options(auto_resize_row_index=True, redraw=False)
4304
+ self.index_align("w", redraw=False)
4294
4305
  return self.set_refresh_timer(redraw)
4295
4306
 
4296
4307
  def set_scrollbar_options(self) -> Sheet:
@@ -4441,6 +4452,60 @@ class Sheet(tk.Frame):
4441
4452
 
4442
4453
  refresh = redraw
4443
4454
 
4455
+ # Progress Bars
4456
+
4457
+ def create_progress_bar(
4458
+ self,
4459
+ row: int,
4460
+ column: int,
4461
+ bg: str,
4462
+ fg: str,
4463
+ name: Hashable,
4464
+ percent: int = 0,
4465
+ del_when_done: bool = False,
4466
+ ) -> Sheet:
4467
+ self.MT.progress_bars[(row, column)] = ProgressBar(
4468
+ bg=bg,
4469
+ fg=fg,
4470
+ name=name,
4471
+ percent=percent,
4472
+ del_when_done=del_when_done,
4473
+ )
4474
+ return self.set_refresh_timer()
4475
+
4476
+ def progress_bar(
4477
+ self,
4478
+ name: Hashable | None = None,
4479
+ cell: tuple[int, int] | None = None,
4480
+ percent: int | None = None,
4481
+ bg: str | None = None,
4482
+ fg: str | None = None,
4483
+ ) -> Sheet:
4484
+ if name is not None:
4485
+ bars = (bar for bar in self.MT.progress_bars.values() if bar.name == name)
4486
+ elif cell is not None:
4487
+ bars = (self.MT.progress_bars[cell],)
4488
+ for bar in bars:
4489
+ if isinstance(percent, int):
4490
+ bar.percent = percent
4491
+ if isinstance(bg, str):
4492
+ bar.bg = bg
4493
+ if isinstance(fg, str):
4494
+ bar.fg = fg
4495
+ return self.set_refresh_timer()
4496
+
4497
+ def del_progress_bar(
4498
+ self,
4499
+ name: Hashable | None = None,
4500
+ cell: tuple[int, int] | None = None,
4501
+ ) -> Sheet:
4502
+ if name is not None:
4503
+ for cell in tuple(cell for cell, bar in self.MT.progress_bars.items() if bar.name == name):
4504
+ del self.MT.progress_bars[cell]
4505
+ elif cell is not None:
4506
+ del self.MT.progress_bars[cell]
4507
+ return self.set_refresh_timer()
4508
+
4444
4509
  # Tags
4445
4510
 
4446
4511
  def tag(
@@ -4681,7 +4746,7 @@ class Sheet(tk.Frame):
4681
4746
  redraw=False,
4682
4747
  deselect_all=False,
4683
4748
  )
4684
- return self.set_refresh_timer(True)
4749
+ return self.set_refresh_timer()
4685
4750
 
4686
4751
  def _tree_open(self, items: set[str]) -> list[int]:
4687
4752
  """
@@ -4793,9 +4858,11 @@ class Sheet(tk.Frame):
4793
4858
  idx += sum(1 for _ in self.RI.get_iid_descendants(cid)) + 1
4794
4859
  else:
4795
4860
  idx = len(self.MT._row_index)
4861
+ if values is None:
4862
+ values = []
4796
4863
  self.insert_rows(
4797
4864
  idx=idx,
4798
- rows=[[self.RI.tree[iid]] + [] if values is None else values],
4865
+ rows=[[self.RI.tree[iid]] + values],
4799
4866
  row_index=True,
4800
4867
  create_selections=create_selections,
4801
4868
  fill=False,
@@ -4914,8 +4981,7 @@ class Sheet(tk.Frame):
4914
4981
  if self.RI.tree[iid].parent and len(self.RI.tree[iid].parent.children) == 1:
4915
4982
  self.RI.tree_open_ids.discard(self.RI.tree[iid].parent.iid)
4916
4983
  del self.RI.tree[iid]
4917
- self.set_refresh_timer(True)
4918
- return self
4984
+ return self.set_refresh_timer()
4919
4985
 
4920
4986
  def set_children(self, parent: str, *newchildren) -> Sheet:
4921
4987
  """
@@ -5004,8 +5070,7 @@ class Sheet(tk.Frame):
5004
5070
  if parent and (parent not in self.RI.tree_open_ids or not self.item_displayed(parent)):
5005
5071
  self.hide_rows(set(mapping.values()), data_indexes=True)
5006
5072
  self.show_rows(to_show)
5007
- self.set_refresh_timer(True)
5008
- return self
5073
+ return self.set_refresh_timer()
5009
5074
 
5010
5075
  reattach = move
5011
5076
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.2.2
3
+ Version: 7.2.4
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
@@ -41,7 +41,7 @@ Description-Content-Type: text/markdown
41
41
  License-File: LICENSE.txt
42
42
 
43
43
  <p align="center" width="100%">
44
- <img width="33%" src="https://github.com/ragardner/tksheet/assets/26602401/4124c3ce-cf62-4925-9158-c5bdf712765b">
44
+ <img width="33%" src="https://github.com/ragardner/tksheet/assets/26602401/4124c3ce-cf62-4925-9158-c5bdf712765b">
45
45
  </p>
46
46
 
47
47
  # <div align="center">tksheet - python tkinter table widget</div>
@@ -82,7 +82,7 @@ This library is maintained with the help of **[others](https://github.com/ragard
82
82
  - Expand row heights and column widths
83
83
  - Change fonts and font size (not for individual cells)
84
84
  - Change any colors in the sheet
85
- - Create an unlimited number of high performance dropdown and check boxes
85
+ - Dropdowns, check boxes, progress bars
86
86
  - [Hide rows and/or columns](https://github.com/ragardner/tksheet/wiki/Version-7#example-header-dropdown-boxes-and-row-filtering)
87
87
  - Left `"w"`, Center `"center"` or Right `"e"` text alignment for any cell/row/column
88
88
 
@@ -0,0 +1,20 @@
1
+ tksheet/__init__.py,sha256=BW3Re3N7ZT4N4duPVUyOe9D4v3KgirJH9kck_Mxl3JA,2124
2
+ tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
+ tksheet/column_headers.py,sha256=PTkKI8OHWn4GzBhPJYU7c8Lz0X52DldV-0J4mPQbjkE,102045
4
+ tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
+ tksheet/functions.py,sha256=rNfDpQRoXZm_Ro-tlF92ox3fi37p71Mio1PGTreM_oc,40835
6
+ tksheet/main_table.py,sha256=VIP-SV3Z9QVH9qVbBth1koI-9PVj6yPQZQ4w_yrVp5U,327474
7
+ tksheet/other_classes.py,sha256=CDN38ZjKxZro9YOS_g0DjMC82-Mi9udedny4wdd90W0,14347
8
+ tksheet/row_index.py,sha256=36e4xgNMwMuvciKLIboKpsiFBrMy_URh7y4OZX8Ygvo,108219
9
+ tksheet/sheet.py,sha256=MWd753gZeFZ4u4w7ZLLSloaIqJg2TNsdvJFvAcxuL-E,270230
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=N9nAj6vcWk4UdcrAakvz2LPbJEJWXdv3j7Om6AnvX5k,14474
13
+ tksheet/top_left_rectangle.py,sha256=o-M6i5NjaJwo60tV-BDP9SbaT1CzQNoPjuoC7p-nb5Q,8436
14
+ tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
+ tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
+ tksheet-7.2.4.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
+ tksheet-7.2.4.dist-info/METADATA,sha256=zPj4U-AFwX_X_Vhzq6SlOAk73teNB50Ple_OvTHLvN4,6284
18
+ tksheet-7.2.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ tksheet-7.2.4.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
+ tksheet-7.2.4.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- tksheet/__init__.py,sha256=AAZRsDaJpm-EpbRjLLHkml18_RHCTN55YebntHKqRRM,2124
2
- tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
- tksheet/column_headers.py,sha256=zArcBsPeob8xUvM0cYB4RjwcKMfLLkHiz7oUtDFBAeg,102039
4
- tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
- tksheet/functions.py,sha256=rNfDpQRoXZm_Ro-tlF92ox3fi37p71Mio1PGTreM_oc,40835
6
- tksheet/main_table.py,sha256=hHO4tuzEBlugZ2k0eOgCcmWXiqEovx7VYIE1KgH4Q0I,324868
7
- tksheet/other_classes.py,sha256=P3FYUYreLhstATvHCNow8sDQoCsD_02KB6oXcca3ahE,13628
8
- tksheet/row_index.py,sha256=aBNZIKMBnbIHdCSsmKdLgZSQ8ESDyAXwFxlSRVR1RO8,108213
9
- tksheet/sheet.py,sha256=rDRy2yg07lpPelfx4zrGQUJXKb7evB9tqzKJupCPXzI,268309
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=N9nAj6vcWk4UdcrAakvz2LPbJEJWXdv3j7Om6AnvX5k,14474
13
- tksheet/top_left_rectangle.py,sha256=o-M6i5NjaJwo60tV-BDP9SbaT1CzQNoPjuoC7p-nb5Q,8436
14
- tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
- tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
- tksheet-7.2.2.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
- tksheet-7.2.2.dist-info/METADATA,sha256=Y0l-rRw47WpKgl3zI2bU5r4AnSSjYpDwX4k404lwvFo,6319
18
- tksheet-7.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- tksheet-7.2.2.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
- tksheet-7.2.2.dist-info/RECORD,,