tksheet 7.2.3__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.3"
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 = {}
@@ -1102,6 +1104,7 @@ class MainTable(tk.Canvas):
1102
1104
  tags: {(k[0], full_new_idxs[k[1]]) for k in tagged} for tags, tagged in self.tagged_cells.items()
1103
1105
  }
1104
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()}
1105
1108
  self.col_options = {full_new_idxs[k]: v for k, v in self.col_options.items()}
1106
1109
  self.tagged_columns = {
1107
1110
  tags: {full_new_idxs[k] for k in tagged} for tags, tagged in self.tagged_columns.items()
@@ -1341,6 +1344,7 @@ class MainTable(tk.Canvas):
1341
1344
  tags: {(full_new_idxs[k[0]], k[1]) for k in tagged} for tags, tagged in self.tagged_cells.items()
1342
1345
  }
1343
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()}
1344
1348
  self.tagged_rows = {tags: {full_new_idxs[k] for k in tagged} for tags, tagged in self.tagged_rows.items()}
1345
1349
  self.row_options = {full_new_idxs[k]: v for k, v in self.row_options.items()}
1346
1350
  self.RI.cell_options = {full_new_idxs[k]: v for k, v in self.RI.cell_options.items()}
@@ -3981,6 +3985,9 @@ class MainTable(tk.Canvas):
3981
3985
  self.cell_options = {
3982
3986
  (r, c if not (num := bisect_right(cols, c)) else c + num): v for (r, c), v in self.cell_options.items()
3983
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
+ }
3984
3991
  self.tagged_columns = {
3985
3992
  tags: {c if not (num := bisect_right(cols, c)) else c + num for c in tagged}
3986
3993
  for tags, tagged in self.tagged_columns.items()
@@ -4050,6 +4057,9 @@ class MainTable(tk.Canvas):
4050
4057
  self.cell_options = {
4051
4058
  (r if not (num := bisect_right(rows, r)) else r + num, c): v for (r, c), v in self.cell_options.items()
4052
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
+ }
4053
4063
  self.tagged_rows = {
4054
4064
  tags: {r if not (num := bisect_right(rows, r)) else r + num for r in tagged}
4055
4065
  for tags, tagged in self.tagged_rows.items()
@@ -4139,6 +4149,14 @@ class MainTable(tk.Canvas):
4139
4149
  for (r, c), v in self.cell_options.items()
4140
4150
  if c not in to_del
4141
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
+ }
4142
4160
  self.tagged_columns = {
4143
4161
  tags: {c if not (num := bisect_left(to_bis, c)) else c - num for c in tagged if c not in to_del}
4144
4162
  for tags, tagged in self.tagged_columns.items()
@@ -4219,6 +4237,14 @@ class MainTable(tk.Canvas):
4219
4237
  for (r, c), v in self.cell_options.items()
4220
4238
  if r not in to_del
4221
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
+ }
4222
4248
  self.tagged_rows = {
4223
4249
  tags: {r if not (num := bisect_left(to_bis, r)) else r - num for r in tagged if r not in to_del}
4224
4250
  for tags, tagged in self.tagged_rows.items()
@@ -5059,7 +5085,10 @@ class MainTable(tk.Canvas):
5059
5085
  can_width: int | None,
5060
5086
  ) -> str:
5061
5087
  redrawn = False
5062
- 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")
5063
5092
  if kwargs:
5064
5093
  if kwargs[0] is not None:
5065
5094
  c_1 = kwargs[0] if kwargs[0].startswith("#") else color_map[kwargs[0]]
@@ -5104,11 +5133,12 @@ class MainTable(tk.Canvas):
5104
5133
  if kwargs[0] is not None:
5105
5134
  fill = kwargs[0]
5106
5135
  if kwargs[0] is not None:
5107
- redrawn = self.redraw_highlight(
5108
- fc + 1,
5109
- fr + 1,
5110
- sc,
5111
- sr,
5136
+ highlight_fn = partial(
5137
+ self.redraw_highlight,
5138
+ x1=fc + 1,
5139
+ y1=fr + 1,
5140
+ x2=sc,
5141
+ y2=sr,
5112
5142
  fill=fill,
5113
5143
  outline=(
5114
5144
  self.PAR.ops.table_fg
@@ -5116,8 +5146,20 @@ class MainTable(tk.Canvas):
5116
5146
  else ""
5117
5147
  ),
5118
5148
  tag="hi",
5119
- can_width=can_width if (len(kwargs) > 2 and kwargs[2]) else None,
5120
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
+ )
5121
5163
  elif not kwargs:
5122
5164
  if "cells" in selections and (r, c) in selections["cells"]:
5123
5165
  tf = self.PAR.ops.table_selected_cells_fg
@@ -5130,13 +5172,15 @@ class MainTable(tk.Canvas):
5130
5172
  return tf, redrawn
5131
5173
 
5132
5174
  def redraw_highlight(self, x1, y1, x2, y2, fill, outline, tag, can_width=None, pc=None):
5133
- if not is_type_int(pc) or pc >= 100 or pc <= 0:
5175
+ if not is_type_int(pc) or pc >= 100:
5134
5176
  coords = (
5135
5177
  x1 - 1 if outline else x1,
5136
5178
  y1 - 1 if outline else y1,
5137
5179
  x2 if can_width is None else x2 + can_width,
5138
5180
  y2,
5139
5181
  )
5182
+ elif pc <= 0:
5183
+ coords = (x1, y1, x1, y2)
5140
5184
  else:
5141
5185
  coords = (x1, y1, (x2 - x1) * (pc / 100), y2)
5142
5186
  if self.hidd_high:
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,
@@ -4445,6 +4452,60 @@ class Sheet(tk.Frame):
4445
4452
 
4446
4453
  refresh = redraw
4447
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
+
4448
4509
  # Tags
4449
4510
 
4450
4511
  def tag(
@@ -4685,7 +4746,7 @@ class Sheet(tk.Frame):
4685
4746
  redraw=False,
4686
4747
  deselect_all=False,
4687
4748
  )
4688
- return self.set_refresh_timer(True)
4749
+ return self.set_refresh_timer()
4689
4750
 
4690
4751
  def _tree_open(self, items: set[str]) -> list[int]:
4691
4752
  """
@@ -4920,8 +4981,7 @@ class Sheet(tk.Frame):
4920
4981
  if self.RI.tree[iid].parent and len(self.RI.tree[iid].parent.children) == 1:
4921
4982
  self.RI.tree_open_ids.discard(self.RI.tree[iid].parent.iid)
4922
4983
  del self.RI.tree[iid]
4923
- self.set_refresh_timer(True)
4924
- return self
4984
+ return self.set_refresh_timer()
4925
4985
 
4926
4986
  def set_children(self, parent: str, *newchildren) -> Sheet:
4927
4987
  """
@@ -5010,8 +5070,7 @@ class Sheet(tk.Frame):
5010
5070
  if parent and (parent not in self.RI.tree_open_ids or not self.item_displayed(parent)):
5011
5071
  self.hide_rows(set(mapping.values()), data_indexes=True)
5012
5072
  self.show_rows(to_show)
5013
- self.set_refresh_timer(True)
5014
- return self
5073
+ return self.set_refresh_timer()
5015
5074
 
5016
5075
  reattach = move
5017
5076
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.2.3
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=ExwA5frHCiXaPMRIH-EKonUH_RKCgMI6IpAps9dtesE,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=CudkuoJ8NSlCwTZjQCxQHRNdBTYdjSyo3CqnIZSmynI,325631
7
- tksheet/other_classes.py,sha256=P3FYUYreLhstATvHCNow8sDQoCsD_02KB6oXcca3ahE,13628
8
- tksheet/row_index.py,sha256=aBNZIKMBnbIHdCSsmKdLgZSQ8ESDyAXwFxlSRVR1RO8,108213
9
- tksheet/sheet.py,sha256=q8MSMTCLHaud-Hddh2vMflWbl785SuiwlZ6H2tam1cw,268536
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.3.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
- tksheet-7.2.3.dist-info/METADATA,sha256=Phxh9tGDvtVNUVESqLiCDYnot995x8l2rhmkJYbOEK4,6319
18
- tksheet-7.2.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- tksheet-7.2.3.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
- tksheet-7.2.3.dist-info/RECORD,,